Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: remoting/host/vlog_net_log.cc

Issue 16137008: Refactor net::NetLog to provide implementation of observer pattern, not just the interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/vlog_net_log.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "remoting/host/vlog_net_log.h" 5 #include "remoting/host/vlog_net_log.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/time.h" 10 #include "base/time.h"
11 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 15
16 VlogNetLog::VlogNetLog() : id_(0) { 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() {
17 } 29 }
18 30
19 VlogNetLog::~VlogNetLog() { 31 VlogNetLog::Observer::~Observer() {
20 } 32 }
21 33
22 void VlogNetLog::OnAddEntry(const NetLog::Entry& entry) { 34 void VlogNetLog::Observer::OnAddEntry(const net::NetLog::Entry& entry) {
23 if (VLOG_IS_ON(4)) { 35 if (VLOG_IS_ON(4)) {
24 scoped_ptr<Value> value(entry.ToValue()); 36 scoped_ptr<Value> value(entry.ToValue());
25 std::string json; 37 std::string json;
26 base::JSONWriter::Write(value.get(), &json); 38 base::JSONWriter::Write(value.get(), &json);
27 VLOG(4) << json; 39 VLOG(4) << json;
28 } 40 }
29 } 41 }
30 42
31 uint32 VlogNetLog::NextID() { 43 VlogNetLog::VlogNetLog()
32 // TODO(mmenke): Make this threadsafe and start with 1 instead of 0. 44 : observer_(new Observer()) {
33 return id_++; 45 AddThreadSafeObserver(observer_.get(), LOG_ALL_BUT_BYTES);
34 } 46 }
35 47
36 net::NetLog::LogLevel VlogNetLog::GetLogLevel() const { 48 VlogNetLog::~VlogNetLog() {
37 return LOG_ALL_BUT_BYTES; 49 RemoveThreadSafeObserver(observer_.get());
38 }
39
40 void VlogNetLog::AddThreadSafeObserver(ThreadSafeObserver* observer,
41 net::NetLog::LogLevel log_level) {
42 NOTIMPLEMENTED();
43 }
44
45 void VlogNetLog::SetObserverLogLevel(ThreadSafeObserver* observer,
46 net::NetLog::LogLevel log_level) {
47 NOTIMPLEMENTED();
48 }
49
50 void VlogNetLog::RemoveThreadSafeObserver(ThreadSafeObserver* observer) {
51 NOTIMPLEMENTED();
52 } 50 }
53 51
54 } // namespace remoting 52 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/vlog_net_log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698