| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "components/google/core/browser/google_util.h" | 16 #include "components/google/core/browser/google_util.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_request_status.h" | 19 #include "net/url_request/url_request_status.h" |
| 20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 21 | 21 |
| 22 WebResourceService::WebResourceService( | 22 WebResourceService::WebResourceService(PrefService* prefs, |
| 23 PrefService* prefs, | 23 const GURL& web_resource_server, |
| 24 const GURL& web_resource_server, | 24 bool apply_locale_to_url, |
| 25 bool apply_locale_to_url, | 25 const char* last_update_time_pref_name, |
| 26 const char* last_update_time_pref_name, | 26 int start_fetch_delay_ms, |
| 27 int start_fetch_delay_ms, | 27 int cache_update_delay_ms) |
| 28 int cache_update_delay_ms) | |
| 29 : prefs_(prefs), | 28 : prefs_(prefs), |
| 29 resource_request_allowed_notifier_(prefs), |
| 30 json_unpacker_(NULL), | 30 json_unpacker_(NULL), |
| 31 in_fetch_(false), | 31 in_fetch_(false), |
| 32 web_resource_server_(web_resource_server), | 32 web_resource_server_(web_resource_server), |
| 33 apply_locale_to_url_(apply_locale_to_url), | 33 apply_locale_to_url_(apply_locale_to_url), |
| 34 last_update_time_pref_name_(last_update_time_pref_name), | 34 last_update_time_pref_name_(last_update_time_pref_name), |
| 35 start_fetch_delay_ms_(start_fetch_delay_ms), | 35 start_fetch_delay_ms_(start_fetch_delay_ms), |
| 36 cache_update_delay_ms_(cache_update_delay_ms), | 36 cache_update_delay_ms_(cache_update_delay_ms), |
| 37 weak_ptr_factory_(this) { | 37 weak_ptr_factory_(this) { |
| 38 resource_request_allowed_notifier_.Init(this); | 38 resource_request_allowed_notifier_.Init(this); |
| 39 DCHECK(prefs); | 39 DCHECK(prefs); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 json_unpacker_->Start(data); | 152 json_unpacker_->Start(data); |
| 153 } else { | 153 } else { |
| 154 // Don't parse data if attempt to download was unsuccessful. | 154 // Don't parse data if attempt to download was unsuccessful. |
| 155 // Stop loading new web resource data, and silently exit. | 155 // Stop loading new web resource data, and silently exit. |
| 156 // We do not call UnpackerClient, so we need to call EndFetch ourselves. | 156 // We do not call UnpackerClient, so we need to call EndFetch ourselves. |
| 157 EndFetch(); | 157 EndFetch(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 Release(); | 160 Release(); |
| 161 } | 161 } |
| OLD | NEW |