Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ | 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 // UI thread. | 40 // UI thread. |
| 41 void ShutdownOnUIThread(); | 41 void ShutdownOnUIThread(); |
| 42 | 42 |
| 43 // --- IO Thread methods. | 43 // --- IO Thread methods. |
| 44 | 44 |
| 45 // The prefetchers need to be deleted on the IO thread. | 45 // The prefetchers need to be deleted on the IO thread. |
| 46 void ShutdownOnIOThread(); | 46 void ShutdownOnIOThread(); |
| 47 | 47 |
| 48 // Will create a new ResourcePrefetcher for a given main frame url if there | 48 // Will create a new ResourcePrefetcher for a given main frame url if there |
| 49 // isn't one already for the same host. | 49 // isn't one already for the same host. |
| 50 void MaybeAddPrefetch(const GURL& main_frame_url, | 50 virtual void MaybeAddPrefetch(const GURL& main_frame_url, |
|
alexilin
2017/05/23 11:01:39
"Virtual for testing" comment?
| |
| 51 const std::vector<GURL>& urls); | 51 const std::vector<GURL>& urls); |
| 52 | 52 |
| 53 // Stops the ResourcePrefetcher for a given main frame URL, if one was in | 53 // Stops the ResourcePrefetcher for a given main frame URL, if one was in |
| 54 // progress. | 54 // progress. |
| 55 void MaybeRemovePrefetch(const GURL& main_frame_url); | 55 void MaybeRemovePrefetch(const GURL& main_frame_url); |
| 56 | 56 |
| 57 // ResourcePrefetcher::Delegate methods. | 57 // ResourcePrefetcher::Delegate methods. |
| 58 void ResourcePrefetcherFinished( | 58 void ResourcePrefetcherFinished( |
| 59 ResourcePrefetcher* prefetcher, | 59 ResourcePrefetcher* prefetcher, |
| 60 std::unique_ptr<ResourcePrefetcher::PrefetcherStats> stats) override; | 60 std::unique_ptr<ResourcePrefetcher::PrefetcherStats> stats) override; |
| 61 net::URLRequestContext* GetURLRequestContext() override; | 61 net::URLRequestContext* GetURLRequestContext() override; |
| 62 | 62 |
| 63 protected: | |
| 64 ~ResourcePrefetcherManager() override; | |
| 65 | |
| 63 private: | 66 private: |
| 64 friend class base::RefCountedThreadSafe<ResourcePrefetcherManager>; | 67 friend class base::RefCountedThreadSafe<ResourcePrefetcherManager>; |
| 65 friend class MockResourcePrefetcherManager; | 68 friend class MockResourcePrefetcherManager; |
| 66 | 69 |
| 67 ~ResourcePrefetcherManager() override; | |
| 68 | |
| 69 ResourcePrefetchPredictor* predictor_; | 70 ResourcePrefetchPredictor* predictor_; |
| 70 const LoadingPredictorConfig config_; | 71 const LoadingPredictorConfig config_; |
| 71 net::URLRequestContextGetter* const context_getter_; | 72 net::URLRequestContextGetter* const context_getter_; |
| 72 | 73 |
| 73 std::map<std::string, std::unique_ptr<ResourcePrefetcher>> prefetcher_map_; | 74 std::map<std::string, std::unique_ptr<ResourcePrefetcher>> prefetcher_map_; |
| 74 | 75 |
| 75 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherManager); | 76 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherManager); |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace predictors | 79 } // namespace predictors |
| 79 | 80 |
| 80 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ | 81 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ |
| OLD | NEW |