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

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

Issue 1530133005: Refactor VariationsHttpHeaderProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing include to srt_fetcher_win.cc. Created 5 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/srt_fetcher_win.h" 5 #include "chrome/browser/safe_browsing/srt_fetcher_win.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/metrics/histogram_macros.h"
15 #include "base/metrics/sparse_histogram.h" 16 #include "base/metrics/sparse_histogram.h"
16 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
17 #include "base/process/launch.h" 18 #include "base/process/launch.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/task_runner_util.h" 22 #include "base/task_runner_util.h"
22 #include "base/threading/thread_checker.h" 23 #include "base/threading/thread_checker.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "base/win/registry.h" 25 #include "base/win/registry.h"
25 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 27 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
27 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/profiles/profile_io_data.h" 29 #include "chrome/browser/profiles/profile_io_data.h"
29 #include "chrome/browser/safe_browsing/srt_field_trial_win.h" 30 #include "chrome/browser/safe_browsing/srt_field_trial_win.h"
30 #include "chrome/browser/safe_browsing/srt_global_error_win.h" 31 #include "chrome/browser/safe_browsing/srt_global_error_win.h"
31 #include "chrome/browser/ui/browser_finder.h" 32 #include "chrome/browser/ui/browser_finder.h"
32 #include "chrome/browser/ui/browser_list.h" 33 #include "chrome/browser/ui/browser_list.h"
33 #include "chrome/browser/ui/browser_list_observer.h" 34 #include "chrome/browser/ui/browser_list_observer.h"
34 #include "chrome/browser/ui/global_error/global_error_service.h" 35 #include "chrome/browser/ui/global_error/global_error_service.h"
35 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 36 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
36 #include "components/component_updater/pref_names.h" 37 #include "components/component_updater/pref_names.h"
37 #include "components/rappor/rappor_service.h" 38 #include "components/rappor/rappor_service.h"
38 #include "components/variations/net/variations_http_header_provider.h" 39 #include "components/variations/net/variations_http_headers.h"
39 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
40 #include "net/base/load_flags.h" 41 #include "net/base/load_flags.h"
41 #include "net/http/http_status_code.h" 42 #include "net/http/http_status_code.h"
42 #include "net/url_request/url_fetcher.h" 43 #include "net/url_request/url_fetcher.h"
43 #include "net/url_request/url_fetcher_delegate.h" 44 #include "net/url_request/url_fetcher_delegate.h"
44 #include "net/url_request/url_request_context_getter.h" 45 #include "net/url_request/url_request_context_getter.h"
45 46
46 using content::BrowserThread; 47 using content::BrowserThread;
47 48
48 namespace safe_browsing { 49 namespace safe_browsing {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); 224 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
224 url_fetcher_->SetMaxRetriesOn5xx(3); 225 url_fetcher_->SetMaxRetriesOn5xx(3);
225 url_fetcher_->SaveResponseToTemporaryFile( 226 url_fetcher_->SaveResponseToTemporaryFile(
226 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); 227 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
227 url_fetcher_->SetRequestContext( 228 url_fetcher_->SetRequestContext(
228 g_browser_process->system_request_context()); 229 g_browser_process->system_request_context());
229 // Adds the UMA bit to the download request if the user is enrolled in UMA. 230 // Adds the UMA bit to the download request if the user is enrolled in UMA.
230 ProfileIOData* io_data = ProfileIOData::FromResourceContext( 231 ProfileIOData* io_data = ProfileIOData::FromResourceContext(
231 profile_->GetResourceContext()); 232 profile_->GetResourceContext());
232 net::HttpRequestHeaders headers; 233 net::HttpRequestHeaders headers;
233 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( 234 variations::AppendVariationHeaders(
234 url_fetcher_->GetOriginalURL(), 235 url_fetcher_->GetOriginalURL(), io_data->IsOffTheRecord(),
235 io_data->IsOffTheRecord(),
236 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(), 236 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(),
237 &headers); 237 &headers);
238 url_fetcher_->SetExtraRequestHeaders(headers.ToString()); 238 url_fetcher_->SetExtraRequestHeaders(headers.ToString());
239 url_fetcher_->Start(); 239 url_fetcher_->Start();
240 } 240 }
241 241
242 // net::URLFetcherDelegate: 242 // net::URLFetcherDelegate:
243 void OnURLFetchComplete(const net::URLFetcher* source) override { 243 void OnURLFetchComplete(const net::URLFetcher* source) override {
244 // Take ownership of the fetcher in this scope (source == url_fetcher_). 244 // Take ownership of the fetcher in this scope (source == url_fetcher_).
245 DCHECK_EQ(url_fetcher_.get(), source); 245 DCHECK_EQ(url_fetcher_.get(), source);
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 608
609 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher) { 609 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher) {
610 g_reporter_launcher_ = reporter_launcher; 610 g_reporter_launcher_ = reporter_launcher;
611 } 611 }
612 612
613 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger) { 613 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger) {
614 g_prompt_trigger_ = prompt_trigger; 614 g_prompt_trigger_ = prompt_trigger;
615 } 615 }
616 616
617 } // namespace safe_browsing 617 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698