Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / remoting / base / vlog_net_log.cc
blobbfcea02a3ae6b07ad6b30cc33267f7724c526a83
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 #include "remoting/base/vlog_net_log.h"
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"
14 namespace remoting {
16 class VlogNetLog::Observer : public net::NetLog::ThreadSafeObserver {
17 public:
18 Observer();
19 ~Observer() override;
21 // NetLog::ThreadSafeObserver overrides:
22 void OnAddEntry(const net::NetLog::Entry& entry) override;
24 private:
25 DISALLOW_COPY_AND_ASSIGN(Observer);
28 VlogNetLog::Observer::Observer() {
31 VlogNetLog::Observer::~Observer() {
34 void VlogNetLog::Observer::OnAddEntry(const net::NetLog::Entry& entry) {
35 if (VLOG_IS_ON(4)) {
36 scoped_ptr<base::Value> value(entry.ToValue());
37 std::string json;
38 base::JSONWriter::Write(*value, &json);
39 VLOG(4) << json;
43 VlogNetLog::VlogNetLog()
44 : observer_(new Observer()) {
45 DeprecatedAddObserver(observer_.get(),
46 net::NetLogCaptureMode::IncludeCookiesAndCredentials());
49 VlogNetLog::~VlogNetLog() {
50 DeprecatedRemoveObserver(observer_.get());
53 } // namespace remoting