Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1803)

Unified Diff: chrome/browser/extensions/api/log_private/log_private_api.h

Issue 329853010: Additional methods for chrome.logPrivate API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: all works Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..da4b0db2f72edd746e7e27301aa0e258321b3f7f 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:
+ typedef enum {
Zachary Kuznia 2014/06/25 00:05:53 Is there a reason to typedef this, instead of usin
zel 2014/06/27 19:31:01 Done.
+ REPORT_EVENTS_TO_EXTENSION,
+ RECORD_EVENTS_TO_FILE,
+ } CapturedEventsSink;
+
// 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_

Powered by Google App Engine
This is Rietveld 408576698