| 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 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 void ShutdownOnUIThread(); | 39 void ShutdownOnUIThread(); |
| 40 | 40 |
| 41 // --- IO Thread methods. | 41 // --- IO Thread methods. |
| 42 | 42 |
| 43 // The prefetchers need to be deleted on the IO thread. | 43 // The prefetchers need to be deleted on the IO thread. |
| 44 void ShutdownOnIOThread(); | 44 void ShutdownOnIOThread(); |
| 45 | 45 |
| 46 // Will create a new ResourcePrefetcher for the main frame url of the input | 46 // Will create a new ResourcePrefetcher for the main frame url of the input |
| 47 // navigation if there isn't one already for the same URL or host (for host | 47 // navigation if there isn't one already for the same URL or host (for host |
| 48 // based). | 48 // based). |
| 49 void MaybeAddPrefetch( | 49 void MaybeAddPrefetch(const NavigationID& navigation_id, |
| 50 const NavigationID& navigation_id, | 50 PrefetchKeyType key_type, |
| 51 PrefetchKeyType key_type, | 51 const std::vector<GURL>& urls); |
| 52 std::unique_ptr<ResourcePrefetcher::RequestVector> requests); | |
| 53 | 52 |
| 54 // Stops the ResourcePrefetcher for the input navigation, if one was in | 53 // Stops the ResourcePrefetcher for the input navigation, if one was in |
| 55 // progress. | 54 // progress. |
| 56 void MaybeRemovePrefetch(const NavigationID& navigation_id); | 55 void MaybeRemovePrefetch(const NavigationID& navigation_id); |
| 57 | 56 |
| 58 // ResourcePrefetcher::Delegate methods. | 57 // ResourcePrefetcher::Delegate methods. |
| 59 void ResourcePrefetcherFinished( | 58 void ResourcePrefetcherFinished(ResourcePrefetcher* prefetcher) override; |
| 60 ResourcePrefetcher* prefetcher, | |
| 61 ResourcePrefetcher::RequestVector* requests) override; | |
| 62 net::URLRequestContext* GetURLRequestContext() override; | 59 net::URLRequestContext* GetURLRequestContext() override; |
| 63 | 60 |
| 64 private: | 61 private: |
| 65 friend class base::RefCountedThreadSafe<ResourcePrefetcherManager>; | 62 friend class base::RefCountedThreadSafe<ResourcePrefetcherManager>; |
| 66 friend class MockResourcePrefetcherManager; | 63 friend class MockResourcePrefetcherManager; |
| 67 | 64 |
| 68 typedef std::map<std::string, ResourcePrefetcher*> PrefetcherMap; | 65 typedef std::map<std::string, ResourcePrefetcher*> PrefetcherMap; |
| 69 | 66 |
| 70 ~ResourcePrefetcherManager() override; | 67 ~ResourcePrefetcherManager() override; |
| 71 | 68 |
| 72 // UI Thread. |predictor_| needs to be called on the UI thread. | |
| 73 void ResourcePrefetcherFinishedOnUI( | |
| 74 const NavigationID& navigation_id, | |
| 75 PrefetchKeyType key_type, | |
| 76 std::unique_ptr<ResourcePrefetcher::RequestVector> requests); | |
| 77 | |
| 78 ResourcePrefetchPredictor* predictor_; | 69 ResourcePrefetchPredictor* predictor_; |
| 79 const ResourcePrefetchPredictorConfig config_; | 70 const ResourcePrefetchPredictorConfig config_; |
| 80 net::URLRequestContextGetter* const context_getter_; | 71 net::URLRequestContextGetter* const context_getter_; |
| 81 | 72 |
| 82 PrefetcherMap prefetcher_map_; // Owns the ResourcePrefetcher pointers. | 73 PrefetcherMap prefetcher_map_; // Owns the ResourcePrefetcher pointers. |
| 83 | 74 |
| 84 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherManager); | 75 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherManager); |
| 85 }; | 76 }; |
| 86 | 77 |
| 87 } // namespace predictors | 78 } // namespace predictors |
| 88 | 79 |
| 89 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ | 80 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ |
| OLD | NEW |