| 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> |
| 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 13 #include "chrome/browser/predictors/resource_prefetch_common.h" | 15 #include "chrome/browser/predictors/resource_prefetch_common.h" |
| 14 #include "chrome/browser/predictors/resource_prefetcher.h" | 16 #include "chrome/browser/predictors/resource_prefetcher.h" |
| 15 | 17 |
| 16 namespace net { | 18 namespace net { |
| 17 class URLRequestContextGetter; | 19 class URLRequestContextGetter; |
| 18 } | 20 } |
| 19 | 21 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 net::URLRequestContextGetter* getter); | 39 net::URLRequestContextGetter* getter); |
| 38 | 40 |
| 39 // UI thread. | 41 // UI thread. |
| 40 void ShutdownOnUIThread(); | 42 void ShutdownOnUIThread(); |
| 41 | 43 |
| 42 // --- IO Thread methods. | 44 // --- IO Thread methods. |
| 43 | 45 |
| 44 // The prefetchers need to be deleted on the IO thread. | 46 // The prefetchers need to be deleted on the IO thread. |
| 45 void ShutdownOnIOThread(); | 47 void ShutdownOnIOThread(); |
| 46 | 48 |
| 47 // Will create a new ResourcePrefetcher for the main frame url of the input | 49 // Will create a new ResourcePrefetcher for a given main frame url if there |
| 48 // navigation if there isn't one already for the same host. | 50 // isn't one already for the same host. |
| 49 void MaybeAddPrefetch(const NavigationID& navigation_id, | 51 void MaybeAddPrefetch(const GURL& main_frame_url, |
| 50 const std::vector<GURL>& urls); | 52 const std::vector<GURL>& urls); |
| 51 | 53 |
| 52 // Stops the ResourcePrefetcher for the input navigation, if one was in | 54 // Stops the ResourcePrefetcher for a given main frame URL, if one was in |
| 53 // progress. | 55 // progress. |
| 54 void MaybeRemovePrefetch(const NavigationID& navigation_id); | 56 void MaybeRemovePrefetch(const GURL& main_frame_url); |
| 55 | 57 |
| 56 // ResourcePrefetcher::Delegate methods. | 58 // ResourcePrefetcher::Delegate methods. |
| 57 void ResourcePrefetcherFinished(ResourcePrefetcher* prefetcher) override; | 59 void ResourcePrefetcherFinished(ResourcePrefetcher* prefetcher) override; |
| 58 net::URLRequestContext* GetURLRequestContext() override; | 60 net::URLRequestContext* GetURLRequestContext() override; |
| 59 | 61 |
| 60 private: | 62 private: |
| 61 friend class base::RefCountedThreadSafe<ResourcePrefetcherManager>; | 63 friend class base::RefCountedThreadSafe<ResourcePrefetcherManager>; |
| 62 friend class MockResourcePrefetcherManager; | 64 friend class MockResourcePrefetcherManager; |
| 63 | 65 |
| 64 ~ResourcePrefetcherManager() override; | 66 ~ResourcePrefetcherManager() override; |
| 65 | 67 |
| 66 ResourcePrefetchPredictor* predictor_; | 68 ResourcePrefetchPredictor* predictor_; |
| 67 const ResourcePrefetchPredictorConfig config_; | 69 const ResourcePrefetchPredictorConfig config_; |
| 68 net::URLRequestContextGetter* const context_getter_; | 70 net::URLRequestContextGetter* const context_getter_; |
| 69 | 71 |
| 70 std::map<std::string, std::unique_ptr<ResourcePrefetcher>> prefetcher_map_; | 72 std::map<std::string, std::unique_ptr<ResourcePrefetcher>> prefetcher_map_; |
| 71 | 73 |
| 72 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherManager); | 74 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherManager); |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 } // namespace predictors | 77 } // namespace predictors |
| 76 | 78 |
| 77 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ | 79 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ |
| OLD | NEW |