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

Unified Diff: net/base/net_log_logger.h

Issue 976483002: Add ability for NetLogLogger to gather data from more than just NetLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments Created 5 years, 10 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
« no previous file with comments | « google_apis/gcm/tools/mcs_probe.cc ('k') | net/base/net_log_logger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_log_logger.h
diff --git a/net/base/net_log_logger.h b/net/base/net_log_logger.h
index ede3ca443db32839305e97af91699de692930baf..0f001c20774710a9a849560d956e9bc7f7bf5936 100644
--- a/net/base/net_log_logger.h
+++ b/net/base/net_log_logger.h
@@ -9,6 +9,7 @@
#include "base/files/scoped_file.h"
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
#include "net/base/net_log.h"
namespace base {
@@ -19,41 +20,52 @@ class Value;
namespace net {
+class URLRequestContext;
+
// NetLogLogger watches the NetLog event stream, and sends all entries to
// a file specified on creation.
//
// The text file will contain a single JSON object.
class NET_EXPORT NetLogLogger : public NetLog::ThreadSafeObserver {
public:
- // Takes ownership of |file| and will write network events to it once logging
- // starts. |file| must be non-NULL handle and be open for writing.
- // |constants| is a legend for decoding constant values used in the log.
- NetLogLogger(FILE* file, const base::Value& constants);
+ NetLogLogger();
~NetLogLogger() override;
// Sets the log level to log at. Must be called before StartObserving.
void set_log_level(NetLog::LogLevel log_level);
- // Starts observing specified NetLog. Must not already be watching a NetLog.
- // Separate from constructor to enforce thread safety.
- void StartObserving(NetLog* net_log);
-
- // Stops observing net_log(). Must already be watching.
+ // Starts observing |net_log| and writes output to |file|. Must not already
+ // be watching a NetLog. Separate from constructor to enforce thread safety.
+ //
+ // |file| must be a non-NULL empty file that's open for writing.
+ //
+ // |constants| is an optional legend for decoding constant values used in the
+ // log. It should generally be a modified version of GetNetConstants(). If
+ // not present, the output of GetNetConstants() will be used.
+ //
+ // |url_request_context| is an optional URLRequestContext to collect
+ // additional information from. When non-NULL, StartObserving and
+ // StopObserving must be called on the context's thread, while the context is
eroman 2015/03/05 19:25:58 I don't like this second requirement. How about in
mmenke 2015/03/05 22:04:17 Done. May make StartObserving take a list of conte
+ // still valid.
+ void StartObserving(NetLog* net_log,
+ base::ScopedFILE file,
+ base::Value* constants,
+ net::URLRequestContext* url_request_context);
mmenke 2015/03/03 18:33:58 One downside of this approach is that we can't get
+
+ // Stops observing net_log(). Must already be watching. Must be called
+ // before destruction of the NetLogLogger and the NetLog. If a
+ // URLRequestContext was passed in to StartObserving, must be called on that
+ // context's thread.
void StopObserving();
// net::NetLog::ThreadSafeObserver implementation:
void OnAddEntry(const NetLog::Entry& entry) override;
- // Create a dictionary containing legend for net/ constants. Caller takes
- // ownership of returned value.
- // TODO(mmenke): Get rid of this, and have embedders use GetNetConstants
- // directly. Also maybe call that function by default, so only embedders
- // that need more constants need to worry about it.
- static base::DictionaryValue* GetConstants();
-
private:
base::ScopedFILE file_;
+ URLRequestContext* url_request_context_;
+
// The LogLevel to log at.
NetLog::LogLevel log_level_;
« no previous file with comments | « google_apis/gcm/tools/mcs_probe.cc ('k') | net/base/net_log_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698