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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 explicit TrackingTestURLRequestContextGetter( | 32 explicit TrackingTestURLRequestContextGetter( |
33 base::MessageLoopProxy* io_message_loop_proxy, | 33 base::MessageLoopProxy* io_message_loop_proxy, |
34 net::URLRequestThrottlerManager* throttler_manager) | 34 net::URLRequestThrottlerManager* throttler_manager) |
35 : TestURLRequestContextGetter(io_message_loop_proxy), | 35 : TestURLRequestContextGetter(io_message_loop_proxy), |
36 throttler_manager_(throttler_manager), | 36 throttler_manager_(throttler_manager), |
37 context_(NULL) { | 37 context_(NULL) { |
38 g_request_context_getter_instances++; | 38 g_request_context_getter_instances++; |
39 } | 39 } |
40 | 40 |
41 virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE { | 41 virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE { |
42 if (!context_) { | 42 if (!context_.get()) { |
43 context_ = new TestURLRequestContext(true); | 43 context_.reset(new TestURLRequestContext(true)); |
44 context_->set_throttler_manager(throttler_manager_); | 44 context_->set_throttler_manager(throttler_manager_); |
45 context_->Init(); | 45 context_->Init(); |
46 } | 46 } |
47 return context_.get(); | 47 return context_.get(); |
48 } | 48 } |
49 | 49 |
50 protected: | 50 protected: |
51 virtual ~TrackingTestURLRequestContextGetter() { | 51 virtual ~TrackingTestURLRequestContextGetter() { |
52 g_request_context_getter_instances--; | 52 g_request_context_getter_instances--; |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 // Not owned here. | 56 // Not owned here. |
57 net::URLRequestThrottlerManager* throttler_manager_; | 57 net::URLRequestThrottlerManager* throttler_manager_; |
58 scoped_refptr<TestURLRequestContext> context_; | 58 scoped_ptr<TestURLRequestContext> context_; |
59 }; | 59 }; |
60 | 60 |
61 class TestCloudPrintURLFetcher : public CloudPrintURLFetcher { | 61 class TestCloudPrintURLFetcher : public CloudPrintURLFetcher { |
62 public: | 62 public: |
63 explicit TestCloudPrintURLFetcher( | 63 explicit TestCloudPrintURLFetcher( |
64 base::MessageLoopProxy* io_message_loop_proxy) | 64 base::MessageLoopProxy* io_message_loop_proxy) |
65 : io_message_loop_proxy_(io_message_loop_proxy) { | 65 : io_message_loop_proxy_(io_message_loop_proxy) { |
66 } | 66 } |
67 | 67 |
68 virtual net::URLRequestContextGetter* GetRequestContextGetter() { | 68 virtual net::URLRequestContextGetter* GetRequestContextGetter() { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 FilePath(kDocRoot)); | 369 FilePath(kDocRoot)); |
370 ASSERT_TRUE(test_server.Start()); | 370 ASSERT_TRUE(test_server.Start()); |
371 | 371 |
372 GURL url(test_server.GetURL("defaultresponse")); | 372 GURL url(test_server.GetURL("defaultresponse")); |
373 CreateFetcher(url, 11); | 373 CreateFetcher(url, 11); |
374 | 374 |
375 MessageLoop::current()->Run(); | 375 MessageLoop::current()->Run(); |
376 } | 376 } |
377 | 377 |
378 } // namespace. | 378 } // namespace. |
OLD | NEW |