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 "content/browser/loader/resource_scheduler.h" | 5 #include "content/browser/loader/resource_scheduler.h" |
6 | 6 |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 virtual ~TestRequest() {} | 58 virtual ~TestRequest() {} |
59 | 59 |
60 bool started() const { return started_; } | 60 bool started() const { return started_; } |
61 | 61 |
62 void Start() { | 62 void Start() { |
63 bool deferred = false; | 63 bool deferred = false; |
64 throttle_->WillStartRequest(&deferred); | 64 throttle_->WillStartRequest(&deferred); |
65 started_ = !deferred; | 65 started_ = !deferred; |
66 } | 66 } |
67 | 67 |
68 virtual void Cancel() OVERRIDE { | 68 virtual void Cancel() override { |
69 // Alert the scheduler that the request can be deleted. | 69 // Alert the scheduler that the request can be deleted. |
70 throttle_.reset(0); | 70 throttle_.reset(0); |
71 } | 71 } |
72 | 72 |
73 const net::URLRequest* url_request() const { return url_request_.get(); } | 73 const net::URLRequest* url_request() const { return url_request_.get(); } |
74 | 74 |
75 protected: | 75 protected: |
76 // ResourceController interface: | 76 // ResourceController interface: |
77 virtual void CancelAndIgnore() OVERRIDE {} | 77 virtual void CancelAndIgnore() override {} |
78 virtual void CancelWithError(int error_code) OVERRIDE {} | 78 virtual void CancelWithError(int error_code) override {} |
79 virtual void Resume() OVERRIDE { started_ = true; } | 79 virtual void Resume() override { started_ = true; } |
80 | 80 |
81 private: | 81 private: |
82 bool started_; | 82 bool started_; |
83 scoped_ptr<ResourceThrottle> throttle_; | 83 scoped_ptr<ResourceThrottle> throttle_; |
84 scoped_ptr<net::URLRequest> url_request_; | 84 scoped_ptr<net::URLRequest> url_request_; |
85 }; | 85 }; |
86 | 86 |
87 class CancelingTestRequest : public TestRequest { | 87 class CancelingTestRequest : public TestRequest { |
88 public: | 88 public: |
89 CancelingTestRequest(scoped_ptr<ResourceThrottle> throttle, | 89 CancelingTestRequest(scoped_ptr<ResourceThrottle> throttle, |
90 scoped_ptr<net::URLRequest> url_request) | 90 scoped_ptr<net::URLRequest> url_request) |
91 : TestRequest(throttle.Pass(), url_request.Pass()) {} | 91 : TestRequest(throttle.Pass(), url_request.Pass()) {} |
92 | 92 |
93 void set_request_to_cancel(scoped_ptr<TestRequest> request_to_cancel) { | 93 void set_request_to_cancel(scoped_ptr<TestRequest> request_to_cancel) { |
94 request_to_cancel_ = request_to_cancel.Pass(); | 94 request_to_cancel_ = request_to_cancel.Pass(); |
95 } | 95 } |
96 | 96 |
97 private: | 97 private: |
98 virtual void Resume() OVERRIDE { | 98 virtual void Resume() override { |
99 TestRequest::Resume(); | 99 TestRequest::Resume(); |
100 request_to_cancel_.reset(); | 100 request_to_cancel_.reset(); |
101 } | 101 } |
102 | 102 |
103 scoped_ptr<TestRequest> request_to_cancel_; | 103 scoped_ptr<TestRequest> request_to_cancel_; |
104 }; | 104 }; |
105 | 105 |
106 class FakeResourceContext : public ResourceContext { | 106 class FakeResourceContext : public ResourceContext { |
107 private: | 107 private: |
108 virtual net::HostResolver* GetHostResolver() OVERRIDE { return NULL; } | 108 virtual net::HostResolver* GetHostResolver() override { return NULL; } |
109 virtual net::URLRequestContext* GetRequestContext() OVERRIDE { return NULL; } | 109 virtual net::URLRequestContext* GetRequestContext() override { return NULL; } |
110 }; | 110 }; |
111 | 111 |
112 class FakeResourceMessageFilter : public ResourceMessageFilter { | 112 class FakeResourceMessageFilter : public ResourceMessageFilter { |
113 public: | 113 public: |
114 FakeResourceMessageFilter(int child_id) | 114 FakeResourceMessageFilter(int child_id) |
115 : ResourceMessageFilter( | 115 : ResourceMessageFilter( |
116 child_id, | 116 child_id, |
117 PROCESS_TYPE_RENDERER, | 117 PROCESS_TYPE_RENDERER, |
118 NULL /* appcache_service */, | 118 NULL /* appcache_service */, |
119 NULL /* blob_storage_context */, | 119 NULL /* blob_storage_context */, |
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 web_contents_2.reset(); | 2171 web_contents_2.reset(); |
2172 base::RunLoop().RunUntilIdle(); | 2172 base::RunLoop().RunUntilIdle(); |
2173 | 2173 |
2174 browser_context.reset(); | 2174 browser_context.reset(); |
2175 render_process_host_factory.reset(); | 2175 render_process_host_factory.reset(); |
2176 } | 2176 } |
2177 | 2177 |
2178 } // unnamed namespace | 2178 } // unnamed namespace |
2179 | 2179 |
2180 } // namespace content | 2180 } // namespace content |
OLD | NEW |