Rename Animate as Begin(Main)Frame
[chromium-blink-merge.git] / content / browser / devtools / devtools_netlog_observer.h
blobf063a3d432c19cb7cc4741633f10163f18145def
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_NETLOG_OBSERVER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_NETLOG_OBSERVER_H_
8 #include "base/containers/hash_tables.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/public/common/resource_devtools_info.h"
11 #include "net/base/net_log.h"
13 namespace net {
14 class URLRequest;
15 } // namespace net
17 namespace content {
18 struct ResourceResponse;
20 // DevToolsNetLogObserver watches the NetLog event stream and collects the
21 // stuff that may be of interest to DevTools. Currently, this only includes
22 // actual HTTP/SPDY headers sent and received over the network.
24 // As DevToolsNetLogObserver shares live data with objects that live on the
25 // IO Thread, it must also reside on the IO Thread. Only OnAddEntry can be
26 // called from other threads.
27 class DevToolsNetLogObserver : public net::NetLog::ThreadSafeObserver {
28 typedef ResourceDevToolsInfo ResourceInfo;
30 public:
31 // net::NetLog::ThreadSafeObserver implementation:
32 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE;
34 void OnAddURLRequestEntry(const net::NetLog::Entry& entry);
36 static void Attach();
37 static void Detach();
39 // Must be called on the IO thread. May return NULL if no observers
40 // are active.
41 static DevToolsNetLogObserver* GetInstance();
42 static void PopulateResponseInfo(net::URLRequest*,
43 ResourceResponse*);
45 private:
46 static DevToolsNetLogObserver* instance_;
48 DevToolsNetLogObserver();
49 virtual ~DevToolsNetLogObserver();
51 ResourceInfo* GetResourceInfo(uint32 id);
53 typedef base::hash_map<uint32, scoped_refptr<ResourceInfo> > RequestToInfoMap;
54 RequestToInfoMap request_to_info_;
56 DISALLOW_COPY_AND_ASSIGN(DevToolsNetLogObserver);
59 } // namespace content
61 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_NETLOG_OBSERVER_H_