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

Side by Side Diff: chrome/browser/debugger/devtools_netlog_observer.cc

Issue 4118004: Update NetLog to be thread safe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Response to comments Created 10 years, 1 month 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/debugger/devtools_netlog_observer.h" 5 #include "chrome/browser/debugger/devtools_netlog_observer.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/io_thread.h" 8 #include "chrome/browser/io_thread.h"
9 #include "chrome/common/resource_response.h" 9 #include "chrome/common/resource_response.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
(...skipping 23 matching lines...) Expand all
34 if (it != request_to_info_.end()) 34 if (it != request_to_info_.end())
35 return it->second; 35 return it->second;
36 return NULL; 36 return NULL;
37 } 37 }
38 38
39 void DevToolsNetLogObserver::OnAddEntry(net::NetLog::EventType type, 39 void DevToolsNetLogObserver::OnAddEntry(net::NetLog::EventType type,
40 const base::TimeTicks& time, 40 const base::TimeTicks& time,
41 const net::NetLog::Source& source, 41 const net::NetLog::Source& source,
42 net::NetLog::EventPhase phase, 42 net::NetLog::EventPhase phase,
43 net::NetLog::EventParameters* params) { 43 net::NetLog::EventParameters* params) {
44 // The events that the Observer is interested in only occur on the IO thread.
45 if (!BrowserThread::CurrentlyOn(BrowserThread::IO))
46 return;
47
44 if (type == net::NetLog::TYPE_URL_REQUEST_START_JOB) { 48 if (type == net::NetLog::TYPE_URL_REQUEST_START_JOB) {
45 if (phase != net::NetLog::PHASE_BEGIN) 49 if (phase != net::NetLog::PHASE_BEGIN)
46 return; 50 return;
47 int load_flags = static_cast<URLRequestStartEventParameters*>(params)-> 51 int load_flags = static_cast<URLRequestStartEventParameters*>(params)->
48 load_flags(); 52 load_flags();
49 if (!(load_flags & net::LOAD_REPORT_RAW_HEADERS)) 53 if (!(load_flags & net::LOAD_REPORT_RAW_HEADERS))
50 return; 54 return;
51 if (request_to_info_.size() > kMaxNumEntries) { 55 if (request_to_info_.size() > kMaxNumEntries) {
52 LOG(WARNING) << "The raw headers observer url request count has grown " 56 LOG(WARNING) << "The raw headers observer url request count has grown "
53 "larger than expected, resetting"; 57 "larger than expected, resetting";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 97 }
94 default: 98 default:
95 break; 99 break;
96 } 100 }
97 } 101 }
98 102
99 void DevToolsNetLogObserver::Attach(IOThread* io_thread) { 103 void DevToolsNetLogObserver::Attach(IOThread* io_thread) {
100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
101 DCHECK(!instance_); 105 DCHECK(!instance_);
102 106
103 instance_ = new DevToolsNetLogObserver(io_thread->globals()->net_log.get()); 107 instance_ = new DevToolsNetLogObserver(io_thread->net_log());
104 } 108 }
105 109
106 void DevToolsNetLogObserver::Detach() { 110 void DevToolsNetLogObserver::Detach() {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
108 DCHECK(instance_); 112 DCHECK(instance_);
109 113
110 delete instance_; 114 delete instance_;
111 instance_ = NULL; 115 instance_ = NULL;
112 } 116 }
113 117
(...skipping 10 matching lines...) Expand all
124 return; 128 return;
125 129
126 uint32 source_id = request->net_log().source().id; 130 uint32 source_id = request->net_log().source().id;
127 DevToolsNetLogObserver* dev_tools_net_log_observer = 131 DevToolsNetLogObserver* dev_tools_net_log_observer =
128 DevToolsNetLogObserver::GetInstance(); 132 DevToolsNetLogObserver::GetInstance();
129 if (!dev_tools_net_log_observer) 133 if (!dev_tools_net_log_observer)
130 return; 134 return;
131 response->response_head.devtools_info = 135 response->response_head.devtools_info =
132 dev_tools_net_log_observer->GetResourceInfo(source_id); 136 dev_tools_net_log_observer->GetResourceInfo(source_id);
133 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698