| 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 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 void Initialize(); | 81 void Initialize(); |
| 82 // ExtensionRegistryObserver implementation. | 82 // ExtensionRegistryObserver implementation. |
| 83 void OnExtensionUnloaded(content::BrowserContext* browser_context, | 83 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 84 const Extension* extension, | 84 const Extension* extension, |
| 85 UnloadedExtensionInfo::Reason reason) override; | 85 UnloadedExtensionInfo::Reason reason) override; |
| 86 | 86 |
| 87 // NetLog::ThreadSafeObserver implementation: | 87 // NetLog::ThreadSafeObserver implementation: |
| 88 void OnAddEntry(const net::NetLog::Entry& entry) override; | 88 void OnAddEntry(const net::NetLog::Entry& entry) override; |
| 89 | 89 |
| 90 void PostPendingEntries(); | 90 void PostPendingEntries(); |
| 91 void AddEntriesOnUI(scoped_ptr<base::ListValue> value); | 91 void AddEntriesOnUI(std::unique_ptr<base::ListValue> value); |
| 92 | 92 |
| 93 // Creates a file that will be written to by net::WriteToFileNetLogObserver. | 93 // Creates a file that will be written to by net::WriteToFileNetLogObserver. |
| 94 void CreateTempNetLogFile(const std::string& owner_extension_id, | 94 void CreateTempNetLogFile(const std::string& owner_extension_id, |
| 95 base::ScopedFILE* file); | 95 base::ScopedFILE* file); |
| 96 | 96 |
| 97 // Starts observing network events with a new |net_logger| instance. | 97 // Starts observing network events with a new |net_logger| instance. |
| 98 void StartObservingNetEvents(IOThread* io_thread, base::ScopedFILE* file); | 98 void StartObservingNetEvents(IOThread* io_thread, base::ScopedFILE* file); |
| 99 void MaybeStartNetInternalLogging(const std::string& caller_extension_id, | 99 void MaybeStartNetInternalLogging(const std::string& caller_extension_id, |
| 100 IOThread* io_thread, | 100 IOThread* io_thread, |
| 101 api::log_private::EventSink event_sink); | 101 api::log_private::EventSink event_sink); |
| 102 void MaybeStopNetInternalLogging(const base::Closure& closure); | 102 void MaybeStopNetInternalLogging(const base::Closure& closure); |
| 103 void StopNetInternalLogging(); | 103 void StopNetInternalLogging(); |
| 104 | 104 |
| 105 // BrowserContextKeyedAPI implementation. | 105 // BrowserContextKeyedAPI implementation. |
| 106 static const char* service_name() { | 106 static const char* service_name() { |
| 107 return "LogPrivateAPI"; | 107 return "LogPrivateAPI"; |
| 108 } | 108 } |
| 109 static const bool kServiceIsNULLWhileTesting = true; | 109 static const bool kServiceIsNULLWhileTesting = true; |
| 110 static const bool kServiceRedirectedInIncognito = true; | 110 static const bool kServiceRedirectedInIncognito = true; |
| 111 | 111 |
| 112 content::BrowserContext* const browser_context_; | 112 content::BrowserContext* const browser_context_; |
| 113 bool logging_net_internals_; | 113 bool logging_net_internals_; |
| 114 api::log_private::EventSink event_sink_; | 114 api::log_private::EventSink event_sink_; |
| 115 std::set<std::string> net_internal_watches_; | 115 std::set<std::string> net_internal_watches_; |
| 116 scoped_ptr<base::ListValue> pending_entries_; | 116 std::unique_ptr<base::ListValue> pending_entries_; |
| 117 scoped_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_; | 117 std::unique_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_; |
| 118 // Listen to extension unloaded notifications. | 118 // Listen to extension unloaded notifications. |
| 119 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 119 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 120 extension_registry_observer_; | 120 extension_registry_observer_; |
| 121 ApiResourceManager<FileResource, WorkerPoolThreadTraits<FileResource> > | 121 ApiResourceManager<FileResource, WorkerPoolThreadTraits<FileResource> > |
| 122 log_file_resources_; | 122 log_file_resources_; |
| 123 bool initialized_; | 123 bool initialized_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(LogPrivateAPI); | 125 DISALLOW_COPY_AND_ASSIGN(LogPrivateAPI); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 class LogPrivateGetHistoricalFunction : public AsyncExtensionFunction { | 128 class LogPrivateGetHistoricalFunction : public AsyncExtensionFunction { |
| 129 public: | 129 public: |
| 130 LogPrivateGetHistoricalFunction(); | 130 LogPrivateGetHistoricalFunction(); |
| 131 DECLARE_EXTENSION_FUNCTION("logPrivate.getHistorical", | 131 DECLARE_EXTENSION_FUNCTION("logPrivate.getHistorical", |
| 132 LOGPRIVATE_GETHISTORICAL); | 132 LOGPRIVATE_GETHISTORICAL); |
| 133 | 133 |
| 134 protected: | 134 protected: |
| 135 ~LogPrivateGetHistoricalFunction() override; | 135 ~LogPrivateGetHistoricalFunction() override; |
| 136 bool RunAsync() override; | 136 bool RunAsync() override; |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 void OnSystemLogsLoaded(scoped_ptr<system_logs::SystemLogsResponse> sys_info); | 139 void OnSystemLogsLoaded( |
| 140 std::unique_ptr<system_logs::SystemLogsResponse> sys_info); |
| 140 | 141 |
| 141 scoped_ptr<FilterHandler> filter_handler_; | 142 std::unique_ptr<FilterHandler> filter_handler_; |
| 142 | 143 |
| 143 DISALLOW_COPY_AND_ASSIGN(LogPrivateGetHistoricalFunction); | 144 DISALLOW_COPY_AND_ASSIGN(LogPrivateGetHistoricalFunction); |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 class LogPrivateStartEventRecorderFunction : public AsyncExtensionFunction { | 147 class LogPrivateStartEventRecorderFunction : public AsyncExtensionFunction { |
| 147 public: | 148 public: |
| 148 LogPrivateStartEventRecorderFunction(); | 149 LogPrivateStartEventRecorderFunction(); |
| 149 DECLARE_EXTENSION_FUNCTION("logPrivate.startEventRecorder", | 150 DECLARE_EXTENSION_FUNCTION("logPrivate.startEventRecorder", |
| 150 LOGPRIVATE_STARTEVENTRECODER); | 151 LOGPRIVATE_STARTEVENTRECODER); |
| 151 | 152 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // Callback for DebugLogWriter::StoreLogs() call. | 193 // Callback for DebugLogWriter::StoreLogs() call. |
| 193 void OnStoreLogsCompleted(const base::FilePath& log_path, bool succeeded); | 194 void OnStoreLogsCompleted(const base::FilePath& log_path, bool succeeded); |
| 194 // Callback for LogPrivateAPI::StopAllWatches() call. | 195 // Callback for LogPrivateAPI::StopAllWatches() call. |
| 195 void OnStopAllWatches(); | 196 void OnStopAllWatches(); |
| 196 DISALLOW_COPY_AND_ASSIGN(LogPrivateDumpLogsFunction); | 197 DISALLOW_COPY_AND_ASSIGN(LogPrivateDumpLogsFunction); |
| 197 }; | 198 }; |
| 198 | 199 |
| 199 } // namespace extensions | 200 } // namespace extensions |
| 200 | 201 |
| 201 #endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PRIVATE_API_H_ | 202 #endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PRIVATE_API_H_ |
| OLD | NEW |