Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/predictors/resource_prefetcher_manager.h

Issue 2318303002: Remove stl_util's STLDeleteContainerPairSecondPointers. (Closed)
Patch Set: fix Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/predictors/resource_prefetch_common.h" 13 #include "chrome/browser/predictors/resource_prefetch_common.h"
13 #include "chrome/browser/predictors/resource_prefetcher.h" 14 #include "chrome/browser/predictors/resource_prefetcher.h"
14 15
15 namespace net { 16 namespace net {
16 class URLRequestContextGetter; 17 class URLRequestContextGetter;
17 } 18 }
18 19
19 namespace predictors { 20 namespace predictors {
20 21
21 struct NavigationID; 22 struct NavigationID;
22 class ResourcePrefetchPredictor; 23 class ResourcePrefetchPredictor;
23 24
24 // Manages prefetches for multple navigations. 25 // Manages prefetches for multiple navigations.
25 // - Created and owned by the resource prefetch predictor. 26 // - Created and owned by the resource prefetch predictor.
26 // - Needs to be refcounted as it is de-referenced on two different threads. 27 // - Needs to be refcounted as it is de-referenced on two different threads.
27 // - Created on the UI thread, but most functions are called in the IO thread. 28 // - Created on the UI thread, but most functions are called in the IO thread.
28 // - Will only allow one inflight prefresh per main frame URL. 29 // - Will only allow one inflight prefresh per main frame URL.
29 class ResourcePrefetcherManager 30 class ResourcePrefetcherManager
30 : public ResourcePrefetcher::Delegate, 31 : public ResourcePrefetcher::Delegate,
31 public base::RefCountedThreadSafe<ResourcePrefetcherManager> { 32 public base::RefCountedThreadSafe<ResourcePrefetcherManager> {
32 public: 33 public:
33 // The |predictor| should be alive till ShutdownOnIOThread is called. 34 // The |predictor| should be alive till ShutdownOnIOThread is called.
34 ResourcePrefetcherManager(ResourcePrefetchPredictor* predictor, 35 ResourcePrefetcherManager(ResourcePrefetchPredictor* predictor,
(...skipping 23 matching lines...) Expand all
58 // ResourcePrefetcher::Delegate methods. 59 // ResourcePrefetcher::Delegate methods.
59 void ResourcePrefetcherFinished( 60 void ResourcePrefetcherFinished(
60 ResourcePrefetcher* prefetcher, 61 ResourcePrefetcher* prefetcher,
61 ResourcePrefetcher::RequestVector* requests) override; 62 ResourcePrefetcher::RequestVector* requests) override;
62 net::URLRequestContext* GetURLRequestContext() override; 63 net::URLRequestContext* GetURLRequestContext() override;
63 64
64 private: 65 private:
65 friend class base::RefCountedThreadSafe<ResourcePrefetcherManager>; 66 friend class base::RefCountedThreadSafe<ResourcePrefetcherManager>;
66 friend class MockResourcePrefetcherManager; 67 friend class MockResourcePrefetcherManager;
67 68
68 typedef std::map<std::string, ResourcePrefetcher*> PrefetcherMap;
69
70 ~ResourcePrefetcherManager() override; 69 ~ResourcePrefetcherManager() override;
71 70
72 // UI Thread. |predictor_| needs to be called on the UI thread. 71 // UI Thread. |predictor_| needs to be called on the UI thread.
73 void ResourcePrefetcherFinishedOnUI( 72 void ResourcePrefetcherFinishedOnUI(
74 const NavigationID& navigation_id, 73 const NavigationID& navigation_id,
75 PrefetchKeyType key_type, 74 PrefetchKeyType key_type,
76 std::unique_ptr<ResourcePrefetcher::RequestVector> requests); 75 std::unique_ptr<ResourcePrefetcher::RequestVector> requests);
77 76
78 ResourcePrefetchPredictor* predictor_; 77 ResourcePrefetchPredictor* predictor_;
79 const ResourcePrefetchPredictorConfig config_; 78 const ResourcePrefetchPredictorConfig config_;
80 net::URLRequestContextGetter* const context_getter_; 79 net::URLRequestContextGetter* const context_getter_;
81 80
82 PrefetcherMap prefetcher_map_; // Owns the ResourcePrefetcher pointers. 81 std::map<std::string, std::unique_ptr<ResourcePrefetcher>> prefetcher_map_;
83 82
84 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherManager); 83 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherManager);
85 }; 84 };
86 85
87 } // namespace predictors 86 } // namespace predictors
88 87
89 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_ 88 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCHER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698