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

Side by Side Diff: chrome/browser/net/chrome_net_log_unittest.cc

Issue 10399083: Make NetLog take in callbacks that return Values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix merge error Created 8 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/chrome_net_log.cc ('k') | chrome/browser/net/load_timing_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/net/chrome_net_log.h" 5 #include "chrome/browser/net/chrome_net_log.h"
6 6
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "base/threading/simple_thread.h" 8 #include "base/threading/simple_thread.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace { 11 namespace {
12 12
13 const int kThreads = 10; 13 const int kThreads = 10;
14 const int kEvents = 100; 14 const int kEvents = 100;
15 15
16 class CountingObserver : public net::NetLog::ThreadSafeObserver { 16 class CountingObserver : public net::NetLog::ThreadSafeObserver {
17 public: 17 public:
18 CountingObserver() : count_(0) {} 18 CountingObserver() : count_(0) {}
19 19
20 ~CountingObserver() { 20 ~CountingObserver() {
21 if (net_log()) 21 if (net_log())
22 net_log()->RemoveThreadSafeObserver(this); 22 net_log()->RemoveThreadSafeObserver(this);
23 } 23 }
24 24
25 virtual void OnAddEntry(net::NetLog::EventType type, 25 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE {
26 const base::TimeTicks& time,
27 const net::NetLog::Source& source,
28 net::NetLog::EventPhase phase,
29 net::NetLog::EventParameters* params) OVERRIDE {
30 ++count_; 26 ++count_;
31 } 27 }
32 28
33 int count() const { return count_; } 29 int count() const { return count_; }
34 30
35 private: 31 private:
36 int count_; 32 int count_;
37 }; 33 };
38 34
39 void AddEvent(ChromeNetLog* net_log) { 35 void AddEvent(ChromeNetLog* net_log) {
40 net_log->AddGlobalEntry(net::NetLog::TYPE_CANCELLED, NULL); 36 net_log->AddGlobalEntry(net::NetLog::TYPE_CANCELLED);
41 } 37 }
42 38
43 // A thread that waits until an event has been signalled before calling 39 // A thread that waits until an event has been signalled before calling
44 // RunTestThread. 40 // RunTestThread.
45 class ChromeNetLogTestThread : public base::SimpleThread { 41 class ChromeNetLogTestThread : public base::SimpleThread {
46 public: 42 public:
47 ChromeNetLogTestThread() : base::SimpleThread("ChromeNetLogTest"), 43 ChromeNetLogTestThread() : base::SimpleThread("ChromeNetLogTest"),
48 net_log_(NULL), 44 net_log_(NULL),
49 start_event_(NULL) { 45 start_event_(NULL) {
50 } 46 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // threads works. 262 // threads works.
267 TEST(ChromeNetLogTest, NetLogAddRemoveObserverThreads) { 263 TEST(ChromeNetLogTest, NetLogAddRemoveObserverThreads) {
268 ChromeNetLog net_log; 264 ChromeNetLog net_log;
269 265
270 // Run a bunch of threads to completion, each of which will repeatedly add 266 // Run a bunch of threads to completion, each of which will repeatedly add
271 // and remove an observer, and set its logging level. 267 // and remove an observer, and set its logging level.
272 RunTestThreads<AddRemoveObserverTestThread>(&net_log); 268 RunTestThreads<AddRemoveObserverTestThread>(&net_log);
273 } 269 }
274 270
275 } // namespace 271 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_net_log.cc ('k') | chrome/browser/net/load_timing_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698