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

Side by Side Diff: chrome/browser/safe_browsing/protocol_manager.cc

Issue 302603008: [Android] Only update safe-browsing database on WiFi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/safe_browsing/protocol_manager.h" 5 #include "chrome/browser/safe_browsing/protocol_manager.h"
6 6
7 #ifndef NDEBUG 7 #ifndef NDEBUG
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #endif 9 #endif
10 #include "base/environment.h" 10 #include "base/environment.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "chrome/browser/safe_browsing/protocol_parser.h" 18 #include "chrome/browser/safe_browsing/protocol_parser.h"
19 #include "chrome/common/chrome_version_info.h" 19 #include "chrome/common/chrome_version_info.h"
20 #include "chrome/common/env_vars.h" 20 #include "chrome/common/env_vars.h"
21 #include "google_apis/google_api_keys.h" 21 #include "google_apis/google_api_keys.h"
22 #include "net/base/escape.h" 22 #include "net/base/escape.h"
23 #include "net/base/load_flags.h" 23 #include "net/base/load_flags.h"
24 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
25 #if defined(OS_ANDROID)
26 #include "net/base/network_change_notifier.h"
27 #endif
Scott Hess - ex-Googler 2014/05/30 16:21:07 The OS-specific section should come after the main
25 #include "net/url_request/url_fetcher.h" 28 #include "net/url_request/url_fetcher.h"
26 #include "net/url_request/url_request_context_getter.h" 29 #include "net/url_request/url_request_context_getter.h"
27 #include "net/url_request/url_request_status.h" 30 #include "net/url_request/url_request_status.h"
28 31
29 using base::Time; 32 using base::Time;
30 using base::TimeDelta; 33 using base::TimeDelta;
31 34
32 namespace { 35 namespace {
33 36
34 // UpdateResult indicates what happened with the primary and/or backup update 37 // UpdateResult indicates what happened with the primary and/or backup update
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 parser.FormatGetHash(prefixes, &get_hash); 193 parser.FormatGetHash(prefixes, &get_hash);
191 194
192 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE); 195 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE);
193 fetcher->SetRequestContext(request_context_getter_.get()); 196 fetcher->SetRequestContext(request_context_getter_.get());
194 fetcher->SetUploadData("text/plain", get_hash); 197 fetcher->SetUploadData("text/plain", get_hash);
195 fetcher->Start(); 198 fetcher->Start();
196 } 199 }
197 200
198 void SafeBrowsingProtocolManager::GetNextUpdate() { 201 void SafeBrowsingProtocolManager::GetNextUpdate() {
199 DCHECK(CalledOnValidThread()); 202 DCHECK(CalledOnValidThread());
200 if (!request_.get() && request_type_ == NO_REQUEST) 203 if (!request_.get() && request_type_ == NO_REQUEST) {
204 #if !defined(OS_ANDROID)
201 IssueUpdateRequest(); 205 IssueUpdateRequest();
Scott Hess - ex-Googler 2014/05/30 16:21:07 This function could be restructured as: { if (r
206 #else
207 net::NetworkChangeNotifier::ConnectionType type =
208 net::NetworkChangeNotifier::GetConnectionType();
209 if (type == net::NetworkChangeNotifier::CONNECTION_WIFI) {
210 IssueUpdateRequest();
211 } else {
212 ScheduleNextUpdate(false /* no back off */);
klobag.chromium 2014/05/30 05:50:15 What is next_update_interval_ look like in common
Scott Hess - ex-Googler 2014/05/30 16:21:07 The server sends things down, it generally seems t
Feng Qian 2014/05/30 17:15:59 If a user is off WiFi for awhile, it will use the
Scott Hess - ex-Googler 2014/05/30 17:24:57 I don't think backoff is right for this case. I t
213 }
214 #endif
215 }
202 } 216 }
203 217
204 // net::URLFetcherDelegate implementation ---------------------------------- 218 // net::URLFetcherDelegate implementation ----------------------------------
205 219
206 // All SafeBrowsing request responses are handled here. 220 // All SafeBrowsing request responses are handled here.
207 // TODO(paulg): Clarify with the SafeBrowsing team whether a failed parse of a 221 // TODO(paulg): Clarify with the SafeBrowsing team whether a failed parse of a
208 // chunk should retry the download and parse of that chunk (and 222 // chunk should retry the download and parse of that chunk (and
209 // what back off / how many times to try), and if that effects the 223 // what back off / how many times to try), and if that effects the
210 // update back off. For now, a failed parse of the chunk means we 224 // update back off. For now, a failed parse of the chunk means we
211 // drop it. This isn't so bad because the next UPDATE_REQUEST we 225 // drop it. This isn't so bad because the next UPDATE_REQUEST we
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 FullHashCallback callback, bool is_download) 797 FullHashCallback callback, bool is_download)
784 : callback(callback), 798 : callback(callback),
785 is_download(is_download) { 799 is_download(is_download) {
786 } 800 }
787 801
788 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { 802 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() {
789 } 803 }
790 804
791 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { 805 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() {
792 } 806 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698