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

Unified Diff: net/base/capturing_net_log.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.h ('k') | net/base/capturing_net_log_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/capturing_net_log.cc
diff --git a/net/base/capturing_net_log.cc b/net/base/capturing_net_log.cc
index 3837fe69b1d8c93ff48bb86ccbd77e6edfcf148b..f2e2c04df7e45e8089b338d08bcff11800374835 100644
--- a/net/base/capturing_net_log.cc
+++ b/net/base/capturing_net_log.cc
@@ -4,130 +4,8 @@
#include "net/base/capturing_net_log.h"
-#include "base/json/json_writer.h"
-#include "base/logging.h"
-#include "base/values.h"
-
namespace net {
-CapturingNetLog::CapturedEntry::CapturedEntry(
- EventType type,
- const base::TimeTicks& time,
- Source source,
- EventPhase phase,
- scoped_ptr<base::DictionaryValue> params)
- : type(type),
- time(time),
- source(source),
- phase(phase),
- params(params.Pass()) {
-}
-
-CapturingNetLog::CapturedEntry::CapturedEntry(const CapturedEntry& entry) {
- *this = entry;
-}
-
-CapturingNetLog::CapturedEntry::~CapturedEntry() {}
-
-CapturingNetLog::CapturedEntry&
-CapturingNetLog::CapturedEntry::operator=(const CapturedEntry& entry) {
- type = entry.type;
- time = entry.time;
- source = entry.source;
- phase = entry.phase;
- params.reset(entry.params ? entry.params->DeepCopy() : NULL);
- return *this;
-}
-
-bool CapturingNetLog::CapturedEntry::GetStringValue(
- const std::string& name,
- std::string* value) const {
- if (!params)
- return false;
- return params->GetString(name, value);
-}
-
-bool CapturingNetLog::CapturedEntry::GetIntegerValue(
- const std::string& name,
- int* value) const {
- if (!params)
- return false;
- return params->GetInteger(name, value);
-}
-
-bool CapturingNetLog::CapturedEntry::GetListValue(
- const std::string& name,
- base::ListValue** value) const {
- if (!params)
- return false;
- return params->GetList(name, value);
-}
-
-bool CapturingNetLog::CapturedEntry::GetNetErrorCode(int* value) const {
- return GetIntegerValue("net_error", value);
-}
-
-std::string CapturingNetLog::CapturedEntry::GetParamsJson() const {
- if (!params)
- return std::string();
- std::string json;
- base::JSONWriter::Write(params.get(), &json);
- return json;
-}
-
-CapturingNetLog::Observer::Observer() {}
-
-CapturingNetLog::Observer::~Observer() {}
-
-void CapturingNetLog::Observer::GetEntries(
- CapturedEntryList* entry_list) const {
- base::AutoLock lock(lock_);
- *entry_list = captured_entries_;
-}
-
-void CapturingNetLog::Observer::GetEntriesForSource(
- NetLog::Source source,
- CapturedEntryList* entry_list) const {
- base::AutoLock lock(lock_);
- entry_list->clear();
- for (CapturedEntryList::const_iterator entry = captured_entries_.begin();
- entry != captured_entries_.end(); ++entry) {
- if (entry->source.id == source.id)
- entry_list->push_back(*entry);
- }
-}
-
-size_t CapturingNetLog::Observer::GetSize() const {
- base::AutoLock lock(lock_);
- return captured_entries_.size();
-}
-
-void CapturingNetLog::Observer::Clear() {
- base::AutoLock lock(lock_);
- captured_entries_.clear();
-}
-
-void CapturingNetLog::Observer::OnAddEntry(const net::NetLog::Entry& entry) {
- // Only BoundNetLogs without a NetLog should have an invalid source.
- CHECK(entry.source().IsValid());
-
- // Using Dictionaries instead of Values makes checking values a little
- // simpler.
- base::DictionaryValue* param_dict = NULL;
- 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(
- CapturedEntry(entry.type(),
- base::TimeTicks::Now(),
- entry.source(),
- entry.phase(),
- scoped_ptr<base::DictionaryValue>(param_dict)));
-}
-
CapturingNetLog::CapturingNetLog() {
AddThreadSafeObserver(&capturing_net_log_observer_, LOG_ALL_BUT_BYTES);
}
« no previous file with comments | « net/base/capturing_net_log.h ('k') | net/base/capturing_net_log_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698