Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chrome/browser/ui/webui/chrome_url_data_manager_backend.cc

Issue 10020052: Added tracing to data-manager's loading of resources. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Switched to async tracing. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" 5 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/debug/trace_event.h"
13 #include "base/file_util.h" 14 #include "base/file_util.h"
14 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
15 #include "base/memory/ref_counted_memory.h" 16 #include "base/memory/ref_counted_memory.h"
16 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
17 #include "base/message_loop.h" 18 #include "base/message_loop.h"
18 #include "base/path_service.h" 19 #include "base/path_service.h"
19 #include "base/string_util.h" 20 #include "base/string_util.h"
20 #include "chrome/browser/net/chrome_url_request_context.h" 21 #include "chrome/browser/net/chrome_url_request_context.h"
21 #include "chrome/browser/ui/webui/shared_resources_data_source.h" 22 #include "chrome/browser/ui/webui/shared_resources_data_source.h"
22 #include "chrome/common/chrome_paths.h" 23 #include "chrome/common/chrome_paths.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 backend_(backend), 223 backend_(backend),
223 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 224 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
224 DCHECK(backend); 225 DCHECK(backend);
225 } 226 }
226 227
227 URLRequestChromeJob::~URLRequestChromeJob() { 228 URLRequestChromeJob::~URLRequestChromeJob() {
228 CHECK(!backend_->HasPendingJob(this)); 229 CHECK(!backend_->HasPendingJob(this));
229 } 230 }
230 231
231 void URLRequestChromeJob::Start() { 232 void URLRequestChromeJob::Start() {
233 TRACE_EVENT_ASYNC_BEGIN1("browser", "DataManager:Request", this, "URL",
234 request_->url().possibly_invalid_spec());
235
232 // Start reading asynchronously so that all error reporting and data 236 // Start reading asynchronously so that all error reporting and data
233 // callbacks happen as they would for network requests. 237 // callbacks happen as they would for network requests.
234 MessageLoop::current()->PostTask( 238 MessageLoop::current()->PostTask(
235 FROM_HERE, 239 FROM_HERE,
236 base::Bind(&URLRequestChromeJob::StartAsync, 240 base::Bind(&URLRequestChromeJob::StartAsync,
237 weak_factory_.GetWeakPtr())); 241 weak_factory_.GetWeakPtr()));
238 } 242 }
239 243
240 void URLRequestChromeJob::Kill() { 244 void URLRequestChromeJob::Kill() {
241 backend_->RemoveRequest(this); 245 backend_->RemoveRequest(this);
242 } 246 }
243 247
244 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const { 248 bool URLRequestChromeJob::GetMimeType(std::string* mime_type) const {
245 *mime_type = mime_type_; 249 *mime_type = mime_type_;
246 return !mime_type_.empty(); 250 return !mime_type_.empty();
247 } 251 }
248 252
249 void URLRequestChromeJob::GetResponseInfo(net::HttpResponseInfo* info) { 253 void URLRequestChromeJob::GetResponseInfo(net::HttpResponseInfo* info) {
250 DCHECK(!info->headers); 254 DCHECK(!info->headers);
251 // Set the headers so that requests serviced by ChromeURLDataManager return a 255 // Set the headers so that requests serviced by ChromeURLDataManager return a
252 // status code of 200. Without this they return a 0, which makes the status 256 // status code of 200. Without this they return a 0, which makes the status
253 // indistiguishable from other error types. Instant relies on getting a 200. 257 // indistiguishable from other error types. Instant relies on getting a 200.
254 info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); 258 info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK");
255 AddContentSecurityPolicyHeader(request_->url(), info->headers); 259 AddContentSecurityPolicyHeader(request_->url(), info->headers);
256 } 260 }
257 261
258 void URLRequestChromeJob::DataAvailable(RefCountedMemory* bytes) { 262 void URLRequestChromeJob::DataAvailable(RefCountedMemory* bytes) {
263 TRACE_EVENT_ASYNC_END0("browser", "DataManager:Request", this);
flackr 2012/04/12 15:04:05 If there's any significant amount of work done in
259 if (bytes) { 264 if (bytes) {
260 // The request completed, and we have all the data. 265 // The request completed, and we have all the data.
261 // Clear any IO pending status. 266 // Clear any IO pending status.
262 SetStatus(net::URLRequestStatus()); 267 SetStatus(net::URLRequestStatus());
263 268
264 data_ = bytes; 269 data_ = bytes;
265 int bytes_read; 270 int bytes_read;
266 if (pending_buf_.get()) { 271 if (pending_buf_.get()) {
267 CHECK(pending_buf_->data()); 272 CHECK(pending_buf_->data());
268 CompleteRead(pending_buf_, pending_buf_size_, &bytes_read); 273 CompleteRead(pending_buf_, pending_buf_size_, &bytes_read);
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 558
554 return new URLRequestChromeJob(request, backend_); 559 return new URLRequestChromeJob(request, backend_);
555 } 560 }
556 561
557 } // namespace 562 } // namespace
558 563
559 net::URLRequestJobFactory::ProtocolHandler* 564 net::URLRequestJobFactory::ProtocolHandler*
560 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend) { 565 CreateDevToolsProtocolHandler(ChromeURLDataManagerBackend* backend) {
561 return new DevToolsJobFactory(backend); 566 return new DevToolsJobFactory(backend);
562 } 567 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698