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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/base/capturing_net_log_observer.h"
6
7 #include "base/values.h"
8
9 namespace net {
10
11 CapturingNetLogObserver::CapturingNetLogObserver() {}
12
13 CapturingNetLogObserver::~CapturingNetLogObserver() {}
14
15 void CapturingNetLogObserver::GetEntries(
16 CapturedNetLogEntry::List* entry_list) const {
17 base::AutoLock lock(lock_);
18 *entry_list = captured_entries_;
19 }
20
21 void CapturingNetLogObserver::GetEntriesForSource(
22 NetLog::Source source,
23 CapturedNetLogEntry::List* entry_list) const {
24 base::AutoLock lock(lock_);
25 entry_list->clear();
26 for (CapturedNetLogEntry::List::const_iterator entry =
27 captured_entries_.begin();
28 entry != captured_entries_.end(); ++entry) {
29 if (entry->source.id == source.id)
30 entry_list->push_back(*entry);
31 }
32 }
33
34 size_t CapturingNetLogObserver::GetSize() const {
35 base::AutoLock lock(lock_);
36 return captured_entries_.size();
37 }
38
39 void CapturingNetLogObserver::Clear() {
40 base::AutoLock lock(lock_);
41 captured_entries_.clear();
42 }
43
44 void CapturingNetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) {
45 // Using Dictionaries instead of Values makes checking values a little
46 // simpler.
47 base::DictionaryValue* param_dict = nullptr;
48 base::Value* param_value = entry.ParametersToValue();
49 if (param_value && !param_value->GetAsDictionary(&param_dict))
50 delete param_value;
51
52 // Only need to acquire the lock when accessing class variables.
53 base::AutoLock lock(lock_);
54 captured_entries_.push_back(
55 CapturedNetLogEntry(entry.type(),
56 base::TimeTicks::Now(),
57 entry.source(),
58 entry.phase(),
59 scoped_ptr<base::DictionaryValue>(param_dict)));
60 }
61
62 } // namespace net
OLDNEW
« 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