| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chrome/browser/predictors/resource_prefetcher.h" | 8 #include "chrome/browser/predictors/resource_prefetcher.h" |
| 9 #include "chrome/browser/predictors/resource_prefetcher_manager.h" | 9 #include "chrome/browser/predictors/resource_prefetcher_manager.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 DISALLOW_COPY_AND_ASSIGN(TestResourcePrefetcher); | 46 DISALLOW_COPY_AND_ASSIGN(TestResourcePrefetcher); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 | 49 |
| 50 // Delegate for ResourcePrefetcher. | 50 // Delegate for ResourcePrefetcher. |
| 51 class TestResourcePrefetcherDelegate : public ResourcePrefetcher::Delegate { | 51 class TestResourcePrefetcherDelegate : public ResourcePrefetcher::Delegate { |
| 52 public: | 52 public: |
| 53 explicit TestResourcePrefetcherDelegate(base::MessageLoop* loop) | 53 explicit TestResourcePrefetcherDelegate(base::MessageLoop* loop) |
| 54 : request_context_getter_(new net::TestURLRequestContextGetter( | 54 : request_context_getter_( |
| 55 loop->message_loop_proxy())) { } | 55 new net::TestURLRequestContextGetter(loop->task_runner())) {} |
| 56 ~TestResourcePrefetcherDelegate() { } | 56 ~TestResourcePrefetcherDelegate() { } |
| 57 | 57 |
| 58 net::URLRequestContext* GetURLRequestContext() override { | 58 net::URLRequestContext* GetURLRequestContext() override { |
| 59 return request_context_getter_->GetURLRequestContext(); | 59 return request_context_getter_->GetURLRequestContext(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 MOCK_METHOD2(ResourcePrefetcherFinished, | 62 MOCK_METHOD2(ResourcePrefetcherFinished, |
| 63 void(ResourcePrefetcher* prefetcher, | 63 void(ResourcePrefetcher* prefetcher, |
| 64 ResourcePrefetcher::RequestVector* requests)); | 64 ResourcePrefetcher::RequestVector* requests)); |
| 65 | 65 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // We need to delete requests_ptr here, though it looks to be managed by the | 352 // We need to delete requests_ptr here, though it looks to be managed by the |
| 353 // scoped_ptr requests. The scoped_ptr requests releases itself and the raw | 353 // scoped_ptr requests. The scoped_ptr requests releases itself and the raw |
| 354 // pointer requests_ptr is passed to ResourcePrefetcherFinished(). In the | 354 // pointer requests_ptr is passed to ResourcePrefetcherFinished(). In the |
| 355 // test, ResourcePrefetcherFinished() is a mock function and does not handle | 355 // test, ResourcePrefetcherFinished() is a mock function and does not handle |
| 356 // the raw pointer properly. In the real code, requests_ptr will eventually be | 356 // the raw pointer properly. In the real code, requests_ptr will eventually be |
| 357 // passed to and managed by ResourcePrefetchPredictor::Result::Result. | 357 // passed to and managed by ResourcePrefetchPredictor::Result::Result. |
| 358 delete requests_ptr; | 358 delete requests_ptr; |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace predictors | 361 } // namespace predictors |
| OLD | NEW |