Revert "Always activate MojoApplicationHost"
[chromium-blink-merge.git] / net / base / net_log_logger.h
blobfde820bd6cd8ee801393c8c13c655760a33ecc0b
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
3 // found in the LICENSE file.
5 #ifndef NET_BASE_NET_LOG_LOGGER_H_
6 #define NET_BASE_NET_LOG_LOGGER_H_
8 #include <stdio.h>
10 #include "base/files/scoped_file.h"
11 #include "base/macros.h"
12 #include "net/base/net_log.h"
14 namespace base {
15 class FilePath;
16 class Value;
19 namespace net {
21 // NetLogLogger watches the NetLog event stream, and sends all entries to
22 // a file specified on creation.
24 // The text file will contain a single JSON object.
25 class NET_EXPORT NetLogLogger : public NetLog::ThreadSafeObserver {
26 public:
27 // Takes ownership of |file| and will write network events to it once logging
28 // starts. |file| must be non-NULL handle and be open for writing.
29 // |constants| is a legend for decoding constant values used in the log.
30 NetLogLogger(FILE* file, const base::Value& constants);
31 virtual ~NetLogLogger();
33 // Sets the log level to log at. Must be called before StartObserving.
34 void set_log_level(NetLog::LogLevel log_level);
36 // Starts observing specified NetLog. Must not already be watching a NetLog.
37 // Separate from constructor to enforce thread safety.
38 void StartObserving(NetLog* net_log);
40 // Stops observing net_log(). Must already be watching.
41 void StopObserving();
43 // net::NetLog::ThreadSafeObserver implementation:
44 virtual void OnAddEntry(const NetLog::Entry& entry) OVERRIDE;
46 // Create a dictionary containing legend for net/ constants. Caller takes
47 // ownership of returned value.
48 static base::DictionaryValue* GetConstants();
50 private:
51 base::ScopedFILE file_;
53 // The LogLevel to log at.
54 NetLog::LogLevel log_level_;
56 // True if OnAddEntry() has been called at least once.
57 bool added_events_;
59 DISALLOW_COPY_AND_ASSIGN(NetLogLogger);
62 } // namespace net
64 #endif // NET_BASE_NET_LOG_LOGGER_H_