| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "chrome/browser/extensions/api/log_private/filter_handler.h" | 11 #include "chrome/browser/extensions/api/log_private/filter_handler.h" |
| 12 #include "chrome/browser/extensions/api/log_private/log_parser.h" | 12 #include "chrome/browser/extensions/api/log_private/log_parser.h" |
| 13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
| 14 #include "chrome/browser/extensions/chrome_extension_function.h" | 13 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 15 #include "chrome/browser/feedback/system_logs/about_system_logs_fetcher.h" | 14 #include "chrome/browser/feedback/system_logs/about_system_logs_fetcher.h" |
| 16 #include "chrome/common/extensions/api/log_private.h" | 15 #include "chrome/common/extensions/api/log_private.h" |
| 17 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 19 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
| 20 | 20 |
| 21 class Profile; | 21 class Profile; |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 class BrowserContext; | 24 class BrowserContext; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace extensions { | 27 namespace extensions { |
| 28 | 28 |
| 29 class LogPrivateAPI : public ProfileKeyedAPI, | 29 class LogPrivateAPI : public BrowserContextKeyedAPI, |
| 30 public content::NotificationObserver, | 30 public content::NotificationObserver, |
| 31 public net::NetLog::ThreadSafeObserver { | 31 public net::NetLog::ThreadSafeObserver { |
| 32 public: | 32 public: |
| 33 // Convenience method to get the LogPrivateAPI for a profile. | 33 // Convenience method to get the LogPrivateAPI for a profile. |
| 34 static LogPrivateAPI* Get(content::BrowserContext* context); | 34 static LogPrivateAPI* Get(content::BrowserContext* context); |
| 35 | 35 |
| 36 explicit LogPrivateAPI(content::BrowserContext* context); | 36 explicit LogPrivateAPI(content::BrowserContext* context); |
| 37 virtual ~LogPrivateAPI(); | 37 virtual ~LogPrivateAPI(); |
| 38 | 38 |
| 39 void StartNetInternalsWatch(const std::string& extension_id); | 39 void StartNetInternalsWatch(const std::string& extension_id); |
| 40 void StopNetInternalsWatch(const std::string& extension_id); | 40 void StopNetInternalsWatch(const std::string& extension_id); |
| 41 | 41 |
| 42 // ProfileKeyedAPI implementation. | 42 // BrowserContextKeyedAPI implementation. |
| 43 static ProfileKeyedAPIFactory<LogPrivateAPI>* GetFactoryInstance(); | 43 static BrowserContextKeyedAPIFactory<LogPrivateAPI>* GetFactoryInstance(); |
| 44 | 44 |
| 45 // content::NotificationObserver implementation. | 45 // content::NotificationObserver implementation. |
| 46 virtual void Observe(int type, | 46 virtual void Observe(int type, |
| 47 const content::NotificationSource& source, | 47 const content::NotificationSource& source, |
| 48 const content::NotificationDetails& details) OVERRIDE; | 48 const content::NotificationDetails& details) OVERRIDE; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 friend class ProfileKeyedAPIFactory<LogPrivateAPI>; | 51 friend class BrowserContextKeyedAPIFactory<LogPrivateAPI>; |
| 52 | 52 |
| 53 // ChromeNetLog::ThreadSafeObserver implementation: | 53 // ChromeNetLog::ThreadSafeObserver implementation: |
| 54 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; | 54 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; |
| 55 | 55 |
| 56 void PostPendingEntries(); | 56 void PostPendingEntries(); |
| 57 void AddEntriesOnUI(scoped_ptr<base::ListValue> value); | 57 void AddEntriesOnUI(scoped_ptr<base::ListValue> value); |
| 58 | 58 |
| 59 void MaybeStartNetInternalLogging(); | 59 void MaybeStartNetInternalLogging(); |
| 60 void MaybeStopNetInternalLogging(); | 60 void MaybeStopNetInternalLogging(); |
| 61 void StopNetInternalLogging(); | 61 void StopNetInternalLogging(); |
| 62 | 62 |
| 63 // ProfileKeyedAPI implementation. | 63 // BrowserContextKeyedAPI implementation. |
| 64 static const char* service_name() { | 64 static const char* service_name() { |
| 65 return "LogPrivateAPI"; | 65 return "LogPrivateAPI"; |
| 66 } | 66 } |
| 67 static const bool kServiceIsNULLWhileTesting = true; | 67 static const bool kServiceIsNULLWhileTesting = true; |
| 68 static const bool kServiceRedirectedInIncognito = true; | 68 static const bool kServiceRedirectedInIncognito = true; |
| 69 | 69 |
| 70 Profile* const profile_; | 70 Profile* const profile_; |
| 71 bool logging_net_internals_; | 71 bool logging_net_internals_; |
| 72 content::NotificationRegistrar registrar_; | 72 content::NotificationRegistrar registrar_; |
| 73 std::set<std::string> net_internal_watches_; | 73 std::set<std::string> net_internal_watches_; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 virtual ~LogPrivateStopNetInternalsWatchFunction(); | 118 virtual ~LogPrivateStopNetInternalsWatchFunction(); |
| 119 virtual bool RunImpl() OVERRIDE; | 119 virtual bool RunImpl() OVERRIDE; |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 DISALLOW_COPY_AND_ASSIGN(LogPrivateStopNetInternalsWatchFunction); | 122 DISALLOW_COPY_AND_ASSIGN(LogPrivateStopNetInternalsWatchFunction); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 } // namespace extensions | 125 } // namespace extensions |
| 126 | 126 |
| 127 #endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PRIVATE_API_H_ | 127 #endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PRIVATE_API_H_ |
| OLD | NEW |