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

Unified Diff: net/base/capturing_net_log_observer.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/capturing_net_log_observer.h ('k') | net/base/file_stream_context_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/capturing_net_log_observer.cc
diff --git a/net/base/capturing_net_log_observer.cc b/net/base/capturing_net_log_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..da99852043088a3d337f22f34024f737e6f560c6
--- /dev/null
+++ b/net/base/capturing_net_log_observer.cc
@@ -0,0 +1,62 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/capturing_net_log_observer.h"
+
+#include "base/values.h"
+
+namespace net {
+
+CapturingNetLogObserver::CapturingNetLogObserver() {}
+
+CapturingNetLogObserver::~CapturingNetLogObserver() {}
+
+void CapturingNetLogObserver::GetEntries(
+ CapturedNetLogEntry::List* entry_list) const {
+ base::AutoLock lock(lock_);
+ *entry_list = captured_entries_;
+}
+
+void CapturingNetLogObserver::GetEntriesForSource(
+ NetLog::Source source,
+ CapturedNetLogEntry::List* entry_list) const {
+ base::AutoLock lock(lock_);
+ entry_list->clear();
+ for (CapturedNetLogEntry::List::const_iterator entry =
+ captured_entries_.begin();
+ entry != captured_entries_.end(); ++entry) {
+ if (entry->source.id == source.id)
+ entry_list->push_back(*entry);
+ }
+}
+
+size_t CapturingNetLogObserver::GetSize() const {
+ base::AutoLock lock(lock_);
+ return captured_entries_.size();
+}
+
+void CapturingNetLogObserver::Clear() {
+ base::AutoLock lock(lock_);
+ captured_entries_.clear();
+}
+
+void CapturingNetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) {
+ // Using Dictionaries instead of Values makes checking values a little
+ // simpler.
+ base::DictionaryValue* param_dict = nullptr;
+ base::Value* param_value = entry.ParametersToValue();
+ if (param_value && !param_value->GetAsDictionary(&param_dict))
+ delete param_value;
+
+ // Only need to acquire the lock when accessing class variables.
+ base::AutoLock lock(lock_);
+ captured_entries_.push_back(
+ CapturedNetLogEntry(entry.type(),
+ base::TimeTicks::Now(),
+ entry.source(),
+ entry.phase(),
+ scoped_ptr<base::DictionaryValue>(param_dict)));
+}
+
+} // namespace net
« no previous file with comments | « net/base/capturing_net_log_observer.h ('k') | net/base/file_stream_context_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698