OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/web_resource/web_resource_service.h" | 5 #include "chrome/browser/web_resource/web_resource_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 ScheduleFetch(delay); | 173 ScheduleFetch(delay); |
174 } | 174 } |
175 | 175 |
176 // Delay initial load of resource data into cache so as not to interfere | 176 // Delay initial load of resource data into cache so as not to interfere |
177 // with startup time. | 177 // with startup time. |
178 void WebResourceService::ScheduleFetch(int64 delay_ms) { | 178 void WebResourceService::ScheduleFetch(int64 delay_ms) { |
179 MessageLoop::current()->PostDelayedTask( | 179 MessageLoop::current()->PostDelayedTask( |
180 FROM_HERE, | 180 FROM_HERE, |
181 base::Bind(&WebResourceService::StartFetch, | 181 base::Bind(&WebResourceService::StartFetch, |
182 weak_ptr_factory_.GetWeakPtr()), | 182 weak_ptr_factory_.GetWeakPtr()), |
183 base::TimeDelta::FromMilliseconds(delay_ms)); | 183 delay_ms); |
184 } | 184 } |
185 | 185 |
186 // Initializes the fetching of data from the resource server. Data | 186 // Initializes the fetching of data from the resource server. Data |
187 // load calls OnURLFetchComplete. | 187 // load calls OnURLFetchComplete. |
188 void WebResourceService::StartFetch() { | 188 void WebResourceService::StartFetch() { |
189 // First, put our next cache load on the MessageLoop. | 189 // First, put our next cache load on the MessageLoop. |
190 ScheduleFetch(cache_update_delay_ms_); | 190 ScheduleFetch(cache_update_delay_ms_); |
191 | 191 |
192 // Set cache update time in preferences. | 192 // Set cache update time in preferences. |
193 prefs_->SetString(last_update_time_pref_name_, | 193 prefs_->SetString(last_update_time_pref_name_, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 std::string data; | 231 std::string data; |
232 source->GetResponseAsString(&data); | 232 source->GetResponseAsString(&data); |
233 | 233 |
234 // UnpackerClient releases itself. | 234 // UnpackerClient releases itself. |
235 UnpackerClient* client = new UnpackerClient(this); | 235 UnpackerClient* client = new UnpackerClient(this); |
236 client->Start(data); | 236 client->Start(data); |
237 | 237 |
238 Release(); | 238 Release(); |
239 } | 239 } |
OLD | NEW |