OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "net/log/net_log.h" | 5 #include "net/log/net_log.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 return 0; | 29 return 0; |
30 if (capture_mode == NetLogCaptureMode::IncludeCookiesAndCredentials()) | 30 if (capture_mode == NetLogCaptureMode::IncludeCookiesAndCredentials()) |
31 return 1; | 31 return 1; |
32 if (capture_mode == NetLogCaptureMode::IncludeSocketBytes()) | 32 if (capture_mode == NetLogCaptureMode::IncludeSocketBytes()) |
33 return 2; | 33 return 2; |
34 | 34 |
35 ADD_FAILURE() << "Unknown capture mode"; | 35 ADD_FAILURE() << "Unknown capture mode"; |
36 return -1; | 36 return -1; |
37 } | 37 } |
38 | 38 |
39 base::Value* CaptureModeToValue(NetLogCaptureMode capture_mode) { | 39 scoped_ptr<base::Value> CaptureModeToValue(NetLogCaptureMode capture_mode) { |
40 return new base::FundamentalValue(CaptureModeToInt(capture_mode)); | 40 return make_scoped_ptr( |
| 41 new base::FundamentalValue(CaptureModeToInt(capture_mode))); |
41 } | 42 } |
42 | 43 |
43 base::Value* NetCaptureModeCallback(NetLogCaptureMode capture_mode) { | 44 scoped_ptr<base::Value> NetCaptureModeCallback(NetLogCaptureMode capture_mode) { |
44 base::DictionaryValue* dict = new base::DictionaryValue(); | 45 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
45 dict->Set("capture_mode", CaptureModeToValue(capture_mode)); | 46 dict->Set("capture_mode", CaptureModeToValue(capture_mode)); |
46 return dict; | 47 return dict.Pass(); |
47 } | 48 } |
48 | 49 |
49 TEST(NetLogTest, Basic) { | 50 TEST(NetLogTest, Basic) { |
50 TestNetLog net_log; | 51 TestNetLog net_log; |
51 TestNetLogEntry::List entries; | 52 TestNetLogEntry::List entries; |
52 net_log.GetEntries(&entries); | 53 net_log.GetEntries(&entries); |
53 EXPECT_EQ(0u, entries.size()); | 54 EXPECT_EQ(0u, entries.size()); |
54 | 55 |
55 net_log.AddGlobalEntry(NetLog::TYPE_CANCELLED); | 56 net_log.AddGlobalEntry(NetLog::TYPE_CANCELLED); |
56 | 57 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 NetLog net_log; | 387 NetLog net_log; |
387 | 388 |
388 // Run a bunch of threads to completion, each of which will repeatedly add | 389 // Run a bunch of threads to completion, each of which will repeatedly add |
389 // and remove an observer, and set its logging level. | 390 // and remove an observer, and set its logging level. |
390 RunTestThreads<AddRemoveObserverTestThread>(&net_log); | 391 RunTestThreads<AddRemoveObserverTestThread>(&net_log); |
391 } | 392 } |
392 | 393 |
393 } // namespace | 394 } // namespace |
394 | 395 |
395 } // namespace net | 396 } // namespace net |
OLD | NEW |