Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 VlogNetLog::VlogNetLog() : id_(0) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 VlogNetLog::~VlogNetLog() { | 19 VlogNetLog::~VlogNetLog() { |
| 20 } | 20 } |
| 21 | 21 |
| 22 void VlogNetLog::AddEntry( | 22 void VlogNetLog::OnAddEntry(const NetLog::Entry& entry) { |
| 23 EventType type, | |
| 24 const Source& source, | |
| 25 EventPhase phase, | |
| 26 const scoped_refptr<EventParameters>& params) { | |
| 27 if (VLOG_IS_ON(4)) { | 23 if (VLOG_IS_ON(4)) { |
| 28 scoped_ptr<Value> value( | 24 scoped_ptr<Value> value(entry.ToValue()); |
| 29 net::NetLog::EntryToDictionaryValue( | |
| 30 type, base::TimeTicks::Now(), source, phase, params, false)); | |
| 31 std::string json; | 25 std::string json; |
| 32 base::JSONWriter::Write(value.get(), &json); | 26 base::JSONWriter::Write(value.get(), &json); |
| 33 VLOG(4) << json; | 27 VLOG(4) << json; |
| 34 } | 28 } |
| 35 } | 29 } |
| 36 | 30 |
| 37 uint32 VlogNetLog::NextID() { | 31 uint32 VlogNetLog::NextID() { |
| 38 return id_++; | 32 return id_++; |
|
mmenke
2012/06/06 17:50:16
This is not threadsafe, and the first ID should be
eroman
2012/06/06 21:27:11
Perhaps add a TODO comment so it doesn't get forgo
mmenke
2012/06/07 19:20:46
Added.
| |
| 39 } | 33 } |
| 40 | 34 |
| 41 net::NetLog::LogLevel VlogNetLog::GetLogLevel() const { | 35 net::NetLog::LogLevel VlogNetLog::GetLogLevel() const { |
| 42 return LOG_ALL_BUT_BYTES; | 36 return LOG_ALL_BUT_BYTES; |
| 43 } | 37 } |
| 44 | 38 |
| 45 void VlogNetLog::AddThreadSafeObserver(ThreadSafeObserver* observer, | 39 void VlogNetLog::AddThreadSafeObserver(ThreadSafeObserver* observer, |
| 46 net::NetLog::LogLevel log_level) { | 40 net::NetLog::LogLevel log_level) { |
| 47 NOTIMPLEMENTED(); | 41 NOTIMPLEMENTED(); |
| 48 } | 42 } |
| 49 | 43 |
| 50 void VlogNetLog::SetObserverLogLevel(ThreadSafeObserver* observer, | 44 void VlogNetLog::SetObserverLogLevel(ThreadSafeObserver* observer, |
| 51 net::NetLog::LogLevel log_level) { | 45 net::NetLog::LogLevel log_level) { |
| 52 NOTIMPLEMENTED(); | 46 NOTIMPLEMENTED(); |
| 53 } | 47 } |
| 54 | 48 |
| 55 void VlogNetLog::RemoveThreadSafeObserver(ThreadSafeObserver* observer) { | 49 void VlogNetLog::RemoveThreadSafeObserver(ThreadSafeObserver* observer) { |
| 56 NOTIMPLEMENTED(); | 50 NOTIMPLEMENTED(); |
| 57 } | 51 } |
| 58 | 52 |
| 59 } // namespace remoting | 53 } // namespace remoting |
| OLD | NEW |