OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/trace_net_log_observer.h" | 5 #include "net/base/trace_net_log_observer.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 class TracedValue : public base::debug::ConvertableToTraceFormat { | 22 class TracedValue : public base::debug::ConvertableToTraceFormat { |
23 public: | 23 public: |
24 explicit TracedValue(scoped_ptr<base::Value> value) : value_(value.Pass()) {} | 24 explicit TracedValue(scoped_ptr<base::Value> value) : value_(value.Pass()) {} |
25 | 25 |
26 private: | 26 private: |
27 virtual ~TracedValue() {} | 27 virtual ~TracedValue() {} |
28 | 28 |
29 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { | 29 virtual void AppendAsTraceFormat(std::string* out) const override { |
30 if (value_) { | 30 if (value_) { |
31 std::string tmp; | 31 std::string tmp; |
32 base::JSONWriter::Write(value_.get(), &tmp); | 32 base::JSONWriter::Write(value_.get(), &tmp); |
33 *out += tmp; | 33 *out += tmp; |
34 } else { | 34 } else { |
35 *out += "\"\""; | 35 *out += "\"\""; |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 private: | 39 private: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 net_log_to_watch_->AddThreadSafeObserver(this, | 97 net_log_to_watch_->AddThreadSafeObserver(this, |
98 NetLog::LOG_STRIP_PRIVATE_DATA); | 98 NetLog::LOG_STRIP_PRIVATE_DATA); |
99 } | 99 } |
100 | 100 |
101 void TraceNetLogObserver::OnTraceLogDisabled() { | 101 void TraceNetLogObserver::OnTraceLogDisabled() { |
102 if (net_log()) | 102 if (net_log()) |
103 net_log()->RemoveThreadSafeObserver(this); | 103 net_log()->RemoveThreadSafeObserver(this); |
104 } | 104 } |
105 | 105 |
106 } // namespace net | 106 } // namespace net |
OLD | NEW |