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

Side by Side Diff: components/precache/core/precache_fetcher.h

Issue 2037903002: Precache manifest should not be added to fetcher pool which is full (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ 5 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_
6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ 6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 namespace precache { 34 namespace precache {
35 35
36 class PrecacheConfigurationSettings; 36 class PrecacheConfigurationSettings;
37 class PrecacheUnfinishedWork; 37 class PrecacheUnfinishedWork;
38 38
39 // Visible for testing. 39 // Visible for testing.
40 extern const int kNoTracking; 40 extern const int kNoTracking;
41 41
42 // Returns the maximum number of URLFetcher requests that can be on flight in
43 // parallel.
44 extern int GetDefaultMaxParallelFetches();
45
42 // Public interface to code that fetches resources that the user is likely to 46 // Public interface to code that fetches resources that the user is likely to
43 // want to fetch in the future, putting them in the network stack disk cache. 47 // want to fetch in the future, putting them in the network stack disk cache.
44 // Precaching is intended to be done when Chrome is not actively in use, likely 48 // Precaching is intended to be done when Chrome is not actively in use, likely
45 // hours ahead of the time when the resources are actually needed. 49 // hours ahead of the time when the resources are actually needed.
46 // 50 //
47 // This class takes as input a prioritized list of URL domains that the user 51 // This class takes as input a prioritized list of URL domains that the user
48 // commonly visits, referred to as starting hosts. This class interacts with a 52 // commonly visits, referred to as starting hosts. This class interacts with a
49 // server, sending it the list of starting hosts sequentially. For each starting 53 // server, sending it the list of starting hosts sequentially. For each starting
50 // host, the server returns a manifest of resource URLs that are good candidates 54 // host, the server returns a manifest of resource URLs that are good candidates
51 // for precaching. Every resource returned is fetched, and responses are cached 55 // for precaching. Every resource returned is fetched, and responses are cached
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Starts fetching resources to precache. URLs are fetched sequentially. Can 121 // Starts fetching resources to precache. URLs are fetched sequentially. Can
118 // be called from any thread. Start should only be called once on a 122 // be called from any thread. Start should only be called once on a
119 // PrecacheFetcher instance. 123 // PrecacheFetcher instance.
120 void Start(); 124 void Start();
121 125
122 // Stops all precaching work. The PreacheFetcher should not be used after 126 // Stops all precaching work. The PreacheFetcher should not be used after
123 // calling this method. 127 // calling this method.
124 std::unique_ptr<PrecacheUnfinishedWork> CancelPrecaching(); 128 std::unique_ptr<PrecacheUnfinishedWork> CancelPrecaching();
125 129
126 private: 130 private:
131 friend class PrecacheFetcherTest;
132
127 // Notifies the precache delete that precaching is done, and report 133 // Notifies the precache delete that precaching is done, and report
128 // completion statistics. 134 // completion statistics.
129 void NotifyDone(size_t remaining_manifest_urls_to_fetch, 135 void NotifyDone(size_t remaining_manifest_urls_to_fetch,
130 size_t remaining_resource_urls_to_fetch); 136 size_t remaining_resource_urls_to_fetch);
131 137
132 // Fetches the next resource or manifest URL, if any remain. Fetching is done 138 // Fetches the next resource or manifest URL, if any remain. Fetching is done
133 // sequentially and depth-first: all resources are fetched for a manifest 139 // sequentially and depth-first: all resources are fetched for a manifest
134 // before the next manifest is fetched. This is done to limit the length of 140 // before the next manifest is fetched. This is done to limit the length of
135 // the |resource_urls_to_fetch_| list, reducing the memory usage. 141 // the |resource_urls_to_fetch_| list, reducing the memory usage.
136 void StartNextFetch(); 142 void StartNextFetch();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 std::unique_ptr<net::URLFetcher> network_url_fetcher_; 251 std::unique_ptr<net::URLFetcher> network_url_fetcher_;
246 int64_t response_bytes_; 252 int64_t response_bytes_;
247 int64_t network_response_bytes_; 253 int64_t network_response_bytes_;
248 254
249 DISALLOW_COPY_AND_ASSIGN(Fetcher); 255 DISALLOW_COPY_AND_ASSIGN(Fetcher);
250 }; 256 };
251 257
252 } // namespace precache 258 } // namespace precache
253 259
254 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ 260 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher.cc » ('j') | components/precache/core/precache_fetcher_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698