isolate_driver: Enable ninja parsing code all the time.
[chromium-blink-merge.git] / net / base / net_log_logger.h
blobc827760068d6c5e7890b90ff093e918e34f73a28
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/memory/scoped_handle.h"
11 #include "net/base/net_log.h"
13 namespace base {
14 class FilePath;
15 class Value;
18 namespace net {
20 // NetLogLogger watches the NetLog event stream, and sends all entries to
21 // a file specified on creation.
23 // The text file will contain a single JSON object.
24 class NET_EXPORT NetLogLogger : public NetLog::ThreadSafeObserver {
25 public:
26 // Takes ownership of |file| and will write network events to it once logging
27 // starts. |file| must be non-NULL handle and be open for writing.
28 // |constants| is a legend for decoding constant values used in the log.
29 NetLogLogger(FILE* file, const base::Value& constants);
30 virtual ~NetLogLogger();
32 // Sets the log level to log at. Must be called before StartObserving.
33 void set_log_level(NetLog::LogLevel log_level);
35 // Starts observing specified NetLog. Must not already be watching a NetLog.
36 // Separate from constructor to enforce thread safety.
37 void StartObserving(NetLog* net_log);
39 // Stops observing net_log(). Must already be watching.
40 void StopObserving();
42 // net::NetLog::ThreadSafeObserver implementation:
43 virtual void OnAddEntry(const NetLog::Entry& entry) OVERRIDE;
45 // Create a dictionary containing legend for net/ constants. Caller takes
46 // ownership of returned value.
47 static base::DictionaryValue* GetConstants();
49 private:
50 ScopedStdioHandle file_;
52 // The LogLevel to log at.
53 NetLog::LogLevel log_level_;
55 // True if OnAddEntry() has been called at least once.
56 bool added_events_;
58 DISALLOW_COPY_AND_ASSIGN(NetLogLogger);
61 } // namespace net
63 #endif // NET_BASE_NET_LOG_LOGGER_H_