| OLD | NEW |
| 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 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_NETLOG_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_NETLOG_OBSERVER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_NETLOG_OBSERVER_H_ | 6 #define CONTENT_BROWSER_LOADER_NETLOG_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "content/public/common/resource_devtools_info.h" | 13 #include "content/public/common/resource_devtools_info.h" |
| 14 #include "net/log/net_log.h" | 14 #include "net/log/net_log.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 class URLRequest; | 17 class URLRequest; |
| 18 } // namespace net | 18 } // namespace net |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 struct ResourceResponse; | 21 struct ResourceResponse; |
| 22 | 22 |
| 23 // DevToolsNetLogObserver watches the NetLog event stream and collects the | 23 // NetLogObserver watches the NetLog event stream and collects the stuff that |
| 24 // stuff that may be of interest to DevTools. Currently, this only includes | 24 // may be of interest to the client. Currently, this only includes actual |
| 25 // actual HTTP/SPDY headers sent and received over the network. | 25 // HTTP/SPDY headers sent and received over the network. |
| 26 // | 26 // |
| 27 // As DevToolsNetLogObserver shares live data with objects that live on the | 27 // As NetLogObserver shares live data with objects that live on the IO Thread, |
| 28 // IO Thread, it must also reside on the IO Thread. Only OnAddEntry can be | 28 // it must also reside on the IO Thread. Only OnAddEntry can be called from |
| 29 // called from other threads. | 29 // other threads. |
| 30 class DevToolsNetLogObserver : public net::NetLog::ThreadSafeObserver { | 30 class NetLogObserver : public net::NetLog::ThreadSafeObserver { |
| 31 typedef ResourceDevToolsInfo ResourceInfo; | 31 typedef ResourceDevToolsInfo ResourceInfo; |
| 32 | 32 |
| 33 public: | 33 public: |
| 34 // net::NetLog::ThreadSafeObserver implementation: | 34 // net::NetLog::ThreadSafeObserver implementation: |
| 35 void OnAddEntry(const net::NetLog::Entry& entry) override; | 35 void OnAddEntry(const net::NetLog::Entry& entry) override; |
| 36 | 36 |
| 37 void OnAddURLRequestEntry(const net::NetLog::Entry& entry); | 37 void OnAddURLRequestEntry(const net::NetLog::Entry& entry); |
| 38 | 38 |
| 39 static void Attach(); | 39 static void Attach(); |
| 40 static void Detach(); | 40 static void Detach(); |
| 41 | 41 |
| 42 // Must be called on the IO thread. May return NULL if no observers | 42 // Must be called on the IO thread. May return NULL if no observers |
| 43 // are active. | 43 // are active. |
| 44 static DevToolsNetLogObserver* GetInstance(); | 44 static NetLogObserver* GetInstance(); |
| 45 static void PopulateResponseInfo(net::URLRequest*, | 45 static void PopulateResponseInfo(net::URLRequest*, ResourceResponse*); |
| 46 ResourceResponse*); | |
| 47 | 46 |
| 48 private: | 47 private: |
| 49 static DevToolsNetLogObserver* instance_; | 48 static NetLogObserver* instance_; |
| 50 | 49 |
| 51 DevToolsNetLogObserver(); | 50 NetLogObserver(); |
| 52 ~DevToolsNetLogObserver() override; | 51 ~NetLogObserver() override; |
| 53 | 52 |
| 54 ResourceInfo* GetResourceInfo(uint32_t id); | 53 ResourceInfo* GetResourceInfo(uint32_t id); |
| 55 | 54 |
| 56 typedef base::hash_map<uint32_t, scoped_refptr<ResourceInfo>> | 55 typedef base::hash_map<uint32_t, scoped_refptr<ResourceInfo>> |
| 57 RequestToInfoMap; | 56 RequestToInfoMap; |
| 58 RequestToInfoMap request_to_info_; | 57 RequestToInfoMap request_to_info_; |
| 59 | 58 |
| 60 DISALLOW_COPY_AND_ASSIGN(DevToolsNetLogObserver); | 59 DISALLOW_COPY_AND_ASSIGN(NetLogObserver); |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 } // namespace content | 62 } // namespace content |
| 64 | 63 |
| 65 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_NETLOG_OBSERVER_H_ | 64 #endif // CONTENT_BROWSER_LOADER_NETLOG_OBSERVER_H_ |
| OLD | NEW |