| Index: net/base/capturing_net_log.cc
|
| diff --git a/net/base/capturing_net_log.cc b/net/base/capturing_net_log.cc
|
| index b90dcae4f860d77ea6fe03bfd910bb5a4a2c8d92..737c2e2c8a285ab86ff4b26e2dd04e202cc90a93 100644
|
| --- a/net/base/capturing_net_log.cc
|
| +++ b/net/base/capturing_net_log.cc
|
| @@ -10,11 +10,11 @@
|
|
|
| namespace net {
|
|
|
| -CapturingNetLog::CapturedEntry::CapturedEntry(
|
| - EventType type,
|
| +CapturingNetLogObserver::CapturedEntry::CapturedEntry(
|
| + NetLog::EventType type,
|
| const base::TimeTicks& time,
|
| - Source source,
|
| - EventPhase phase,
|
| + NetLog::Source source,
|
| + NetLog::EventPhase phase,
|
| scoped_ptr<DictionaryValue> params)
|
| : type(type),
|
| time(time),
|
| @@ -23,14 +23,15 @@ CapturingNetLog::CapturedEntry::CapturedEntry(
|
| params(params.Pass()) {
|
| }
|
|
|
| -CapturingNetLog::CapturedEntry::CapturedEntry(const CapturedEntry& entry) {
|
| +CapturingNetLogObserver::CapturedEntry::CapturedEntry(
|
| + const CapturedEntry& entry) {
|
| *this = entry;
|
| }
|
|
|
| -CapturingNetLog::CapturedEntry::~CapturedEntry() {}
|
| +CapturingNetLogObserver::CapturedEntry::~CapturedEntry() {}
|
|
|
| -CapturingNetLog::CapturedEntry&
|
| -CapturingNetLog::CapturedEntry::operator=(const CapturedEntry& entry) {
|
| +CapturingNetLogObserver::CapturedEntry&
|
| +CapturingNetLogObserver::CapturedEntry::operator=(const CapturedEntry& entry) {
|
| type = entry.type;
|
| time = entry.time;
|
| source = entry.source;
|
| @@ -39,7 +40,7 @@ CapturingNetLog::CapturedEntry::operator=(const CapturedEntry& entry) {
|
| return *this;
|
| }
|
|
|
| -bool CapturingNetLog::CapturedEntry::GetStringValue(
|
| +bool CapturingNetLogObserver::CapturedEntry::GetStringValue(
|
| const std::string& name,
|
| std::string* value) const {
|
| if (!params)
|
| @@ -47,7 +48,7 @@ bool CapturingNetLog::CapturedEntry::GetStringValue(
|
| return params->GetString(name, value);
|
| }
|
|
|
| -bool CapturingNetLog::CapturedEntry::GetIntegerValue(
|
| +bool CapturingNetLogObserver::CapturedEntry::GetIntegerValue(
|
| const std::string& name,
|
| int* value) const {
|
| if (!params)
|
| @@ -55,11 +56,11 @@ bool CapturingNetLog::CapturedEntry::GetIntegerValue(
|
| return params->GetInteger(name, value);
|
| }
|
|
|
| -bool CapturingNetLog::CapturedEntry::GetNetErrorCode(int* value) const {
|
| +bool CapturingNetLogObserver::CapturedEntry::GetNetErrorCode(int* value) const {
|
| return GetIntegerValue("net_error", value);
|
| }
|
|
|
| -std::string CapturingNetLog::CapturedEntry::GetParamsJson() const {
|
| +std::string CapturingNetLogObserver::CapturedEntry::GetParamsJson() const {
|
| if (!params)
|
| return std::string();
|
| std::string json;
|
| @@ -67,19 +68,16 @@ std::string CapturingNetLog::CapturedEntry::GetParamsJson() const {
|
| return json;
|
| }
|
|
|
| -CapturingNetLog::CapturingNetLog()
|
| - : last_id_(0),
|
| - log_level_(LOG_ALL_BUT_BYTES) {
|
| -}
|
| +CapturingNetLogObserver::CapturingNetLogObserver() {}
|
|
|
| -CapturingNetLog::~CapturingNetLog() {}
|
| +CapturingNetLogObserver::~CapturingNetLogObserver() {}
|
|
|
| -void CapturingNetLog::GetEntries(CapturedEntryList* entry_list) const {
|
| +void CapturingNetLogObserver::GetEntries(CapturedEntryList* entry_list) const {
|
| base::AutoLock lock(lock_);
|
| *entry_list = captured_entries_;
|
| }
|
|
|
| -void CapturingNetLog::GetEntriesForSource(NetLog::Source source,
|
| +void CapturingNetLogObserver::GetEntriesForSource(NetLog::Source source,
|
| CapturedEntryList* entry_list) const {
|
| base::AutoLock lock(lock_);
|
| entry_list->clear();
|
| @@ -90,22 +88,17 @@ void CapturingNetLog::GetEntriesForSource(NetLog::Source source,
|
| }
|
| }
|
|
|
| -size_t CapturingNetLog::GetSize() const {
|
| +size_t CapturingNetLogObserver::GetSize() const {
|
| base::AutoLock lock(lock_);
|
| return captured_entries_.size();
|
| }
|
|
|
| -void CapturingNetLog::Clear() {
|
| +void CapturingNetLogObserver::Clear() {
|
| base::AutoLock lock(lock_);
|
| captured_entries_.clear();
|
| }
|
|
|
| -void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) {
|
| - base::AutoLock lock(lock_);
|
| - log_level_ = log_level;
|
| -}
|
| -
|
| -void CapturingNetLog::OnAddEntry(const net::NetLog::Entry& entry) {
|
| +void CapturingNetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) {
|
| // Only BoundNetLogs without a NetLog should have an invalid source.
|
| CHECK(entry.source().IsValid());
|
|
|
| @@ -126,59 +119,55 @@ void CapturingNetLog::OnAddEntry(const net::NetLog::Entry& entry) {
|
| scoped_ptr<DictionaryValue>(param_dict)));
|
| }
|
|
|
| -uint32 CapturingNetLog::NextID() {
|
| - return base::subtle::NoBarrier_AtomicIncrement(&last_id_, 1);
|
| +CapturingNetLog::CapturingNetLog() {
|
| + AddThreadSafeObserver(&capturing_net_log_observer_, LOG_ALL_BUT_BYTES);
|
| }
|
|
|
| -NetLog::LogLevel CapturingNetLog::GetLogLevel() const {
|
| - base::AutoLock lock(lock_);
|
| - return log_level_;
|
| +CapturingNetLog::~CapturingNetLog() {
|
| + RemoveThreadSafeObserver(&capturing_net_log_observer_);
|
| }
|
|
|
| -void CapturingNetLog::AddThreadSafeObserver(
|
| - NetLog::ThreadSafeObserver* observer,
|
| - NetLog::LogLevel log_level) {
|
| - NOTIMPLEMENTED() << "Not currently used by net unit tests.";
|
| +void CapturingNetLog::SetLogLevel(NetLog::LogLevel log_level) {
|
| + SetObserverLogLevel(&capturing_net_log_observer_, log_level);
|
| }
|
|
|
| -void CapturingNetLog::SetObserverLogLevel(ThreadSafeObserver* observer,
|
| - LogLevel log_level) {
|
| - NOTIMPLEMENTED() << "Not currently used by net unit tests.";
|
| +void CapturingNetLog::GetEntries(
|
| + CapturingNetLogObserver::CapturedEntryList* entry_list) const {
|
| + capturing_net_log_observer_.GetEntries(entry_list);
|
| }
|
|
|
| -void CapturingNetLog::RemoveThreadSafeObserver(
|
| - NetLog::ThreadSafeObserver* observer) {
|
| - NOTIMPLEMENTED() << "Not currently used by net unit tests.";
|
| +size_t CapturingNetLog::GetSize() const {
|
| + return capturing_net_log_observer_.GetSize();
|
| }
|
|
|
| CapturingBoundNetLog::CapturingBoundNetLog()
|
| - : net_log_(BoundNetLog::Make(&capturing_net_log_,
|
| - net::NetLog::SOURCE_NONE)) {
|
| + : bound_net_log_(BoundNetLog::Make(&net_log_,
|
| + net::NetLog::SOURCE_NONE)) {
|
| }
|
|
|
| CapturingBoundNetLog::~CapturingBoundNetLog() {}
|
|
|
| void CapturingBoundNetLog::GetEntries(
|
| - CapturingNetLog::CapturedEntryList* entry_list) const {
|
| - capturing_net_log_.GetEntries(entry_list);
|
| + CapturingNetLogObserver::CapturedEntryList* entry_list) const {
|
| + net_log_.observer().GetEntries(entry_list);
|
| }
|
|
|
| void CapturingBoundNetLog::GetEntriesForSource(
|
| NetLog::Source source,
|
| - CapturingNetLog::CapturedEntryList* entry_list) const {
|
| - capturing_net_log_.GetEntriesForSource(source, entry_list);
|
| + CapturingNetLogObserver::CapturedEntryList* entry_list) const {
|
| + net_log_.observer().GetEntriesForSource(source, entry_list);
|
| }
|
|
|
| size_t CapturingBoundNetLog::GetSize() const {
|
| - return capturing_net_log_.GetSize();
|
| + return net_log_.observer().GetSize();
|
| }
|
|
|
| void CapturingBoundNetLog::Clear() {
|
| - capturing_net_log_.Clear();
|
| + net_log_.observer().Clear();
|
| }
|
|
|
| void CapturingBoundNetLog::SetLogLevel(NetLog::LogLevel log_level) {
|
| - capturing_net_log_.SetLogLevel(log_level);
|
| + net_log_.SetLogLevel(log_level);
|
| }
|
|
|
| } // namespace net
|
|
|