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