| OLD | NEW |
| 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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 ++count_; | 30 ++count_; |
| 31 } | 31 } |
| 32 | 32 |
| 33 int count() const { return count_; } | 33 int count() const { return count_; } |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 int count_; | 36 int count_; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 void AddEvent(ChromeNetLog* net_log) { | 39 void AddEvent(ChromeNetLog* net_log) { |
| 40 net::NetLog::Source source(net::NetLog::SOURCE_SOCKET, net_log->NextID()); | 40 net_log->AddGlobalEntry(net::NetLog::TYPE_CANCELLED, NULL); |
| 41 net_log->AddEntry(net::NetLog::TYPE_SOCKET_ALIVE, base::TimeTicks(), | |
| 42 source, net::NetLog::PHASE_BEGIN, NULL); | |
| 43 } | 41 } |
| 44 | 42 |
| 45 // A thread that waits until an event has been signalled before calling | 43 // A thread that waits until an event has been signalled before calling |
| 46 // RunTestThread. | 44 // RunTestThread. |
| 47 class ChromeNetLogTestThread : public base::SimpleThread { | 45 class ChromeNetLogTestThread : public base::SimpleThread { |
| 48 public: | 46 public: |
| 49 ChromeNetLogTestThread() : base::SimpleThread("ChromeNetLogTest"), | 47 ChromeNetLogTestThread() : base::SimpleThread("ChromeNetLogTest"), |
| 50 net_log_(NULL), | 48 net_log_(NULL), |
| 51 start_event_(NULL) { | 49 start_event_(NULL) { |
| 52 } | 50 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // threads works. | 266 // threads works. |
| 269 TEST(ChromeNetLogTest, NetLogAddRemoveObserverThreads) { | 267 TEST(ChromeNetLogTest, NetLogAddRemoveObserverThreads) { |
| 270 ChromeNetLog net_log; | 268 ChromeNetLog net_log; |
| 271 | 269 |
| 272 // Run a bunch of threads to completion, each of which will repeatedly add | 270 // Run a bunch of threads to completion, each of which will repeatedly add |
| 273 // and remove an observer, and set its logging level. | 271 // and remove an observer, and set its logging level. |
| 274 RunTestThreads<AddRemoveObserverTestThread>(&net_log); | 272 RunTestThreads<AddRemoveObserverTestThread>(&net_log); |
| 275 } | 273 } |
| 276 | 274 |
| 277 } // namespace | 275 } // namespace |
| OLD | NEW |