| Index: chrome/browser/extensions/api/log_private/log_private_api.h
|
| diff --git a/chrome/browser/extensions/api/log_private/log_private_api.h b/chrome/browser/extensions/api/log_private/log_private_api.h
|
| index 2b6648bcfdd88822b2915f3fb28a6d05e168267a..259101520ff78b57794cfc4d3a076f485c8be2d7 100644
|
| --- a/chrome/browser/extensions/api/log_private/log_private_api.h
|
| +++ b/chrome/browser/extensions/api/log_private/log_private_api.h
|
| @@ -17,6 +17,7 @@
|
| #include "extensions/browser/browser_context_keyed_api_factory.h"
|
| #include "extensions/browser/extension_registry_observer.h"
|
| #include "net/base/net_log.h"
|
| +#include "net/base/net_log_logger.h"
|
|
|
| namespace content {
|
| class BrowserContext;
|
| @@ -29,14 +30,23 @@ class LogPrivateAPI : public BrowserContextKeyedAPI,
|
| public ExtensionRegistryObserver,
|
| public net::NetLog::ThreadSafeObserver {
|
| public:
|
| + enum CapturedEventsSink {
|
| + REPORT_EVENTS_TO_EXTENSION,
|
| + RECORD_EVENTS_TO_FILE,
|
| + };
|
| +
|
| // Convenience method to get the LogPrivateAPI for a profile.
|
| static LogPrivateAPI* Get(content::BrowserContext* context);
|
|
|
| explicit LogPrivateAPI(content::BrowserContext* context);
|
| virtual ~LogPrivateAPI();
|
|
|
| - void StartNetInternalsWatch(const std::string& extension_id);
|
| - void StopNetInternalsWatch(const std::string& extension_id);
|
| + void StartNetInternalsWatch(const std::string& extension_id,
|
| + CapturedEventsSink event_sink);
|
| + void StopNetInternalsWatch(const std::string& extension_id,
|
| + const base::Closure& closure);
|
| + void StopAllWatches(const std::string& extension_id,
|
| + const base::Closure& closure);
|
|
|
| // BrowserContextKeyedAPI implementation.
|
| static BrowserContextKeyedAPIFactory<LogPrivateAPI>* GetFactoryInstance();
|
| @@ -56,8 +66,8 @@ class LogPrivateAPI : public BrowserContextKeyedAPI,
|
| void PostPendingEntries();
|
| void AddEntriesOnUI(scoped_ptr<base::ListValue> value);
|
|
|
| - void MaybeStartNetInternalLogging();
|
| - void MaybeStopNetInternalLogging();
|
| + void MaybeStartNetInternalLogging(CapturedEventsSink event_sink);
|
| + void MaybeStopNetInternalLogging(const base::Closure& closure);
|
| void StopNetInternalLogging();
|
|
|
| // BrowserContextKeyedAPI implementation.
|
| @@ -69,8 +79,10 @@ class LogPrivateAPI : public BrowserContextKeyedAPI,
|
|
|
| content::BrowserContext* const browser_context_;
|
| bool logging_net_internals_;
|
| + CapturedEventsSink event_sink_;
|
| std::set<std::string> net_internal_watches_;
|
| scoped_ptr<base::ListValue> pending_entries_;
|
| + scoped_ptr<net::NetLogLogger> net_log_logger_;
|
|
|
| // Listen to extension unloaded notifications.
|
| ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
|
| @@ -125,6 +137,60 @@ class LogPrivateStopNetInternalsWatchFunction
|
| DISALLOW_COPY_AND_ASSIGN(LogPrivateStopNetInternalsWatchFunction);
|
| };
|
|
|
| +
|
| +class LogPrivateStartEventRecorderFunction
|
| + : public ChromeSyncExtensionFunction {
|
| + public:
|
| + LogPrivateStartEventRecorderFunction();
|
| + DECLARE_EXTENSION_FUNCTION("logPrivate.startEventRecorder",
|
| + LOGPRIVATE_STARTEVENTRECODER);
|
| +
|
| + protected:
|
| + virtual ~LogPrivateStartEventRecorderFunction();
|
| + virtual bool RunSync() OVERRIDE;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(LogPrivateStartEventRecorderFunction);
|
| +};
|
| +
|
| +class LogPrivateStopEventRecorderFunction
|
| + : public ChromeSyncExtensionFunction {
|
| + public:
|
| + LogPrivateStopEventRecorderFunction();
|
| + DECLARE_EXTENSION_FUNCTION("logPrivate.stopEventRecorder",
|
| + LOGPRIVATE_STOPEVENTRECODER);
|
| +
|
| + protected:
|
| + virtual ~LogPrivateStopEventRecorderFunction();
|
| + virtual bool RunSync() OVERRIDE;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(LogPrivateStopEventRecorderFunction);
|
| +};
|
| +
|
| +class LogPrivateDumpLogsFunction
|
| + : public AsyncExtensionFunction {
|
| + public:
|
| + LogPrivateDumpLogsFunction();
|
| + DECLARE_EXTENSION_FUNCTION("logPrivate.dumpLogs",
|
| + LOGPRIVATE_DUMPLOGS);
|
| +
|
| + protected:
|
| + virtual ~LogPrivateDumpLogsFunction();
|
| +
|
| + // AsyncExtensionFunction overrides.
|
| + virtual bool RunAsync() OVERRIDE;
|
| +
|
| + private:
|
| + // Callback for DebugLogWriter::StoreLogs() call.
|
| + void OnStoreLogsCompleted(const base::FilePath& log_path,
|
| + bool succeeded);
|
| + // Callback for LogPrivateAPI::StopAllWatches() call.
|
| + void OnStopAllWatches();
|
| + DISALLOW_COPY_AND_ASSIGN(LogPrivateDumpLogsFunction);
|
| +};
|
| +
|
| +
|
| } // namespace extensions
|
|
|
| #endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PRIVATE_API_H_
|
|
|