OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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. | |
4 | |
5 #include "remoting/host/vlog_net_log.h" | |
6 | |
7 #include "base/json/json_writer.h" | |
8 #include "base/logging.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/threading/thread_restrictions.h" | |
11 #include "base/time/time.h" | |
12 #include "base/values.h" | |
13 | |
14 namespace remoting { | |
15 | |
16 class VlogNetLog::Observer : public net::NetLog::ThreadSafeObserver { | |
17 public: | |
18 Observer(); | |
19 virtual ~Observer(); | |
20 | |
21 // NetLog::ThreadSafeObserver overrides: | |
22 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; | |
23 | |
24 private: | |
25 DISALLOW_COPY_AND_ASSIGN(Observer); | |
26 }; | |
27 | |
28 VlogNetLog::Observer::Observer() { | |
29 } | |
30 | |
31 VlogNetLog::Observer::~Observer() { | |
32 } | |
33 | |
34 void VlogNetLog::Observer::OnAddEntry(const net::NetLog::Entry& entry) { | |
35 if (VLOG_IS_ON(4)) { | |
36 scoped_ptr<Value> value(entry.ToValue()); | |
37 std::string json; | |
38 base::JSONWriter::Write(value.get(), &json); | |
39 VLOG(4) << json; | |
40 } | |
41 } | |
42 | |
43 VlogNetLog::VlogNetLog() | |
44 : observer_(new Observer()) { | |
45 AddThreadSafeObserver(observer_.get(), LOG_ALL_BUT_BYTES); | |
46 } | |
47 | |
48 VlogNetLog::~VlogNetLog() { | |
49 RemoveThreadSafeObserver(observer_.get()); | |
50 } | |
51 | |
52 } // namespace remoting | |
OLD | NEW |