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

Unified 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: Requires threadsafe observers 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/debugger/devtools_netlog_observer.cc
===================================================================
--- chrome/browser/debugger/devtools_netlog_observer.cc (revision 65207)
+++ chrome/browser/debugger/devtools_netlog_observer.cc (working copy)
@@ -14,6 +14,22 @@
#include "net/url_request/url_request_netlog_params.h"
#include "webkit/glue/resource_loader_bridge.h"
+namespace {
+
+void AddEntryOnIOThread(
+ DevToolsNetLogObserver* observer,
+ net::NetLog::EventType type,
+ const base::TimeTicks& time,
+ const net::NetLog::Source& source,
+ net::NetLog::EventPhase phase,
+ scoped_refptr<net::NetLog::EventParameters> params) {
+ if (observer == DevToolsNetLogObserver::GetInstance()) {
+ observer->OnAddEntry(type, time, source, phase, params.get());
+ }
+}
+
+} // namespace
+
const size_t kMaxNumEntries = 1000;
DevToolsNetLogObserver* DevToolsNetLogObserver::instance_ = NULL;
@@ -41,6 +57,16 @@
const net::NetLog::Source& source,
net::NetLog::EventPhase phase,
net::NetLog::EventParameters* params) {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ BrowserThread::PostTask(BrowserThread::IO,
eroman 2010/11/16 17:51:14 Can we instead just return immediately if we aren'
mmenke 2010/11/16 21:34:49 I'm not quite sure, actually. Do we care about th
+ FROM_HERE,
+ NewRunnableFunction(
+ AddEntryOnIOThread,
+ this, type, time, source, phase,
+ make_scoped_refptr(params)));
+ return;
+ }
+
if (type == net::NetLog::TYPE_URL_REQUEST_START_JOB) {
if (phase != net::NetLog::PHASE_BEGIN)
return;
@@ -100,7 +126,7 @@
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(!instance_);
- instance_ = new DevToolsNetLogObserver(io_thread->globals()->net_log.get());
+ instance_ = new DevToolsNetLogObserver(io_thread->net_log());
}
void DevToolsNetLogObserver::Detach() {

Powered by Google App Engine
This is Rietveld 408576698