forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement chrome://blob-internals with network service.
BUG=717714 Review-Url: https://codereview.chromium.org/2865243002 Cr-Commit-Position: refs/heads/master@{#470423}
- Loading branch information
jam
authored and
Commit bot
committed
May 9, 2017
1 parent
069cf2c
commit d654ee5
Showing
6 changed files
with
131 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "content/browser/blob_storage/blob_internals_url_loader.h" | ||
|
||
#include "content/browser/blob_storage/blob_internals_url_loader.h" | ||
#include "content/browser/blob_storage/chrome_blob_storage_context.h" | ||
#include "storage/browser/blob/view_blob_internals_job.h" | ||
|
||
namespace content { | ||
|
||
void StartBlobInternalsURLLoader( | ||
const ResourceRequest& request, | ||
mojom::URLLoaderClientPtrInfo client_info, | ||
ChromeBlobStorageContext* blob_storage_context) { | ||
scoped_refptr<net::HttpResponseHeaders> headers( | ||
new net::HttpResponseHeaders("HTTP/1.1 200 OK")); | ||
ResourceResponseHead resource_response; | ||
resource_response.headers = headers; | ||
resource_response.mime_type = "text/html"; | ||
|
||
mojom::URLLoaderClientPtr client; | ||
client.Bind(std::move(client_info)); | ||
client->OnReceiveResponse(resource_response, base::nullopt, nullptr); | ||
|
||
std::string output = storage::ViewBlobInternalsJob::GenerateHTML( | ||
blob_storage_context->context()); | ||
|
||
MojoCreateDataPipeOptions options; | ||
options.struct_size = sizeof(MojoCreateDataPipeOptions); | ||
options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE; | ||
options.element_num_bytes = 1; | ||
options.capacity_num_bytes = output.size(); | ||
mojo::DataPipe data_pipe(options); | ||
|
||
DCHECK(data_pipe.producer_handle.is_valid()); | ||
DCHECK(data_pipe.consumer_handle.is_valid()); | ||
|
||
void* buffer = nullptr; | ||
uint32_t num_bytes = output.size(); | ||
MojoResult result = | ||
BeginWriteDataRaw(data_pipe.producer_handle.get(), &buffer, &num_bytes, | ||
MOJO_WRITE_DATA_FLAG_NONE); | ||
CHECK_EQ(result, MOJO_RESULT_OK); | ||
CHECK_EQ(num_bytes, output.size()); | ||
|
||
memcpy(buffer, output.c_str(), output.size()); | ||
result = EndWriteDataRaw(data_pipe.producer_handle.get(), num_bytes); | ||
CHECK_EQ(result, MOJO_RESULT_OK); | ||
|
||
client->OnStartLoadingResponseBody(std::move(data_pipe.consumer_handle)); | ||
|
||
ResourceRequestCompletionStatus request_complete_data; | ||
request_complete_data.error_code = net::OK; | ||
request_complete_data.exists_in_cache = false; | ||
request_complete_data.completion_time = base::TimeTicks::Now(); | ||
request_complete_data.encoded_data_length = output.size(); | ||
request_complete_data.encoded_body_length = output.size(); | ||
client->OnComplete(request_complete_data); | ||
} | ||
|
||
} // namespace content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CONTENT_BROWSER_BLOB_STORAGE_BLOB_INTERNALS_URL_LOADER_H_ | ||
#define CONTENT_BROWSER_BLOB_STORAGE_BLOB_INTERNALS_URL_LOADER_H_ | ||
|
||
#include "content/common/url_loader.mojom.h" | ||
|
||
namespace content { | ||
class ChromeBlobStorageContext; | ||
|
||
void StartBlobInternalsURLLoader( | ||
const ResourceRequest& request, | ||
mojom::URLLoaderClientPtrInfo client_info, | ||
ChromeBlobStorageContext* blob_storage_context); | ||
} // namespace content | ||
|
||
#endif // CONTENT_BROWSER_BLOB_STORAGE_VIEW_BLOB_INTERNALS_URL_LOADER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters