OLD | NEW |
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 #include "components/precache/core/precache_fetcher.h" | 5 #include "components/precache/core/precache_fetcher.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "components/precache/core/precache_switches.h" | 14 #include "components/precache/core/precache_switches.h" |
15 #include "components/precache/core/proto/precache.pb.h" | 15 #include "components/precache/core/proto/precache.pb.h" |
16 #include "net/base/escape.h" | 16 #include "net/base/escape.h" |
17 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
18 #include "net/url_request/url_fetcher.h" | 18 #include "net/url_request/url_fetcher.h" |
19 #include "net/url_request/url_fetcher_delegate.h" | 19 #include "net/url_request/url_fetcher_delegate.h" |
20 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
21 #include "net/url_request/url_request_status.h" | 21 #include "net/url_request/url_request_status.h" |
22 | 22 |
23 using net::URLFetcher; | 23 using net::URLFetcher; |
24 | 24 |
25 namespace precache { | 25 namespace precache { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 GURL GetConfigURL() { | 29 GURL GetConfigURL() { |
30 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 30 const base::CommandLine& command_line = |
| 31 *base::CommandLine::ForCurrentProcess(); |
31 if (command_line.HasSwitch(switches::kPrecacheConfigSettingsURL)) { | 32 if (command_line.HasSwitch(switches::kPrecacheConfigSettingsURL)) { |
32 return GURL( | 33 return GURL( |
33 command_line.GetSwitchValueASCII(switches::kPrecacheConfigSettingsURL)); | 34 command_line.GetSwitchValueASCII(switches::kPrecacheConfigSettingsURL)); |
34 } | 35 } |
35 | 36 |
36 #if defined(PRECACHE_CONFIG_SETTINGS_URL) | 37 #if defined(PRECACHE_CONFIG_SETTINGS_URL) |
37 return GURL(PRECACHE_CONFIG_SETTINGS_URL); | 38 return GURL(PRECACHE_CONFIG_SETTINGS_URL); |
38 #else | 39 #else |
39 // The precache config settings URL could not be determined, so return an | 40 // The precache config settings URL could not be determined, so return an |
40 // empty, invalid GURL. | 41 // empty, invalid GURL. |
41 return GURL(); | 42 return GURL(); |
42 #endif | 43 #endif |
43 } | 44 } |
44 | 45 |
45 std::string GetManifestURLPrefix() { | 46 std::string GetManifestURLPrefix() { |
46 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 47 const base::CommandLine& command_line = |
| 48 *base::CommandLine::ForCurrentProcess(); |
47 if (command_line.HasSwitch(switches::kPrecacheManifestURLPrefix)) { | 49 if (command_line.HasSwitch(switches::kPrecacheManifestURLPrefix)) { |
48 return command_line.GetSwitchValueASCII( | 50 return command_line.GetSwitchValueASCII( |
49 switches::kPrecacheManifestURLPrefix); | 51 switches::kPrecacheManifestURLPrefix); |
50 } | 52 } |
51 | 53 |
52 #if defined(PRECACHE_MANIFEST_URL_PREFIX) | 54 #if defined(PRECACHE_MANIFEST_URL_PREFIX) |
53 return PRECACHE_MANIFEST_URL_PREFIX; | 55 return PRECACHE_MANIFEST_URL_PREFIX; |
54 #else | 56 #else |
55 // The precache manifest URL prefix could not be determined, so return an | 57 // The precache manifest URL prefix could not be determined, so return an |
56 // empty string. | 58 // empty string. |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 StartNextFetch(); | 248 StartNextFetch(); |
247 } | 249 } |
248 | 250 |
249 void PrecacheFetcher::OnResourceFetchComplete(const URLFetcher& source) { | 251 void PrecacheFetcher::OnResourceFetchComplete(const URLFetcher& source) { |
250 // The resource has already been put in the cache during the fetch process, so | 252 // The resource has already been put in the cache during the fetch process, so |
251 // nothing more needs to be done for the resource. | 253 // nothing more needs to be done for the resource. |
252 StartNextFetch(); | 254 StartNextFetch(); |
253 } | 255 } |
254 | 256 |
255 } // namespace precache | 257 } // namespace precache |
OLD | NEW |