From 70019150e9f7f53074cacb335de0d238bbc37380 Mon Sep 17 00:00:00 2001 From: "pfeldman@chromium.org" Date: Wed, 19 Dec 2012 11:44:19 +0000 Subject: DevTools: rename debugger/ to devtools/, move DevTools files into content/renderer/devtools. Review URL: https://codereview.chromium.org/11630004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173903 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/devtools/devtools_netlog_observer.h | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 content/browser/devtools/devtools_netlog_observer.h (limited to 'content/browser/devtools/devtools_netlog_observer.h') diff --git a/content/browser/devtools/devtools_netlog_observer.h b/content/browser/devtools/devtools_netlog_observer.h new file mode 100644 index 0000000..4e74edd --- /dev/null +++ b/content/browser/devtools/devtools_netlog_observer.h @@ -0,0 +1,70 @@ +// Copyright (c) 2012 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_DEVTOOLS_DEVTOOLS_NETLOG_OBSERVER_H_ +#define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_NETLOG_OBSERVER_H_ + +#include "base/hash_tables.h" +#include "base/memory/ref_counted.h" +#include "net/base/net_log.h" +#include "webkit/glue/resource_loader_bridge.h" + +namespace net { +class URLRequest; +} // namespace net + +namespace content { +struct ResourceResponse; + +// DevToolsNetLogObserver watches the NetLog event stream and collects the +// stuff that may be of interest to DevTools. Currently, this only includes +// actual HTTP/SPDY headers sent and received over the network. +// +// As DevToolsNetLogObserver shares live data with objects that live on the +// IO Thread, it must also reside on the IO Thread. Only OnAddEntry can be +// called from other threads. +class DevToolsNetLogObserver : public net::NetLog::ThreadSafeObserver { + typedef webkit_glue::ResourceDevToolsInfo ResourceInfo; + + public: + // net::NetLog::ThreadSafeObserver implementation: + virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; + + void OnAddURLRequestEntry(const net::NetLog::Entry& entry); + void OnAddHTTPStreamJobEntry(const net::NetLog::Entry& entry); + void OnAddSocketEntry(const net::NetLog::Entry& entry); + + static void Attach(); + static void Detach(); + + // Must be called on the IO thread. May return NULL if no observers + // are active. + static DevToolsNetLogObserver* GetInstance(); + static void PopulateResponseInfo(net::URLRequest*, + ResourceResponse*); + static int GetAndResetEncodedDataLength(net::URLRequest* request); + + private: + static DevToolsNetLogObserver* instance_; + + DevToolsNetLogObserver(); + virtual ~DevToolsNetLogObserver(); + + ResourceInfo* GetResourceInfo(uint32 id); + + typedef base::hash_map > RequestToInfoMap; + typedef base::hash_map RequestToEncodedDataLengthMap; + typedef base::hash_map HTTPStreamJobToSocketMap; + typedef base::hash_map SocketToRequestMap; + RequestToInfoMap request_to_info_; + RequestToEncodedDataLengthMap request_to_encoded_data_length_; + HTTPStreamJobToSocketMap http_stream_job_to_socket_; + SocketToRequestMap socket_to_request_; + + DISALLOW_COPY_AND_ASSIGN(DevToolsNetLogObserver); +}; + +} // namespace content + +#endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_NETLOG_OBSERVER_H_ -- cgit v1.1