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

Side by Side Diff: components/feedback/feedback_uploader_chrome.cc

Issue 942863003: Fix variation id transmission with feedback reports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Exclude test on Android + fix leak in test + rebase. Created 5 years, 10 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
« no previous file with comments | « components/feedback/DEPS ('k') | components/feedback/feedback_uploader_chrome_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/feedback/feedback_uploader_chrome.h" 5 #include "components/feedback/feedback_uploader_chrome.h"
6 6
7 #include <string>
8
7 #include "base/callback.h" 9 #include "base/callback.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
10 #include "base/task_runner_util.h" 12 #include "base/task_runner_util.h"
11 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
12 #include "components/feedback/feedback_report.h" 14 #include "components/feedback/feedback_report.h"
13 #include "components/feedback/feedback_switches.h" 15 #include "components/feedback/feedback_switches.h"
14 #include "components/feedback/feedback_uploader_delegate.h" 16 #include "components/feedback/feedback_uploader_delegate.h"
17 #include "components/variations/net/variations_http_header_provider.h"
15 #include "content/public/browser/browser_context.h" 18 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
17 #include "net/base/load_flags.h" 20 #include "net/base/load_flags.h"
18 #include "net/url_request/url_fetcher.h" 21 #include "net/url_request/url_fetcher.h"
19 #include "url/gurl.h" 22 #include "url/gurl.h"
20 23
21 using content::BrowserThread; 24 using content::BrowserThread;
22 25
23 namespace feedback { 26 namespace feedback {
24 namespace { 27 namespace {
(...skipping 10 matching lines...) Expand all
35 CHECK(context_); 38 CHECK(context_);
36 const base::CommandLine& command_line = 39 const base::CommandLine& command_line =
37 *base::CommandLine::ForCurrentProcess(); 40 *base::CommandLine::ForCurrentProcess();
38 if (command_line.HasSwitch(switches::kFeedbackServer)) 41 if (command_line.HasSwitch(switches::kFeedbackServer))
39 url_ = command_line.GetSwitchValueASCII(switches::kFeedbackServer); 42 url_ = command_line.GetSwitchValueASCII(switches::kFeedbackServer);
40 } 43 }
41 44
42 void FeedbackUploaderChrome::DispatchReport(const std::string& data) { 45 void FeedbackUploaderChrome::DispatchReport(const std::string& data) {
43 GURL post_url(url_); 46 GURL post_url(url_);
44 47
48 // Note: FeedbackUploaderDelegate deletes itself and the fetcher.
45 net::URLFetcher* fetcher = net::URLFetcher::Create( 49 net::URLFetcher* fetcher = net::URLFetcher::Create(
46 post_url, net::URLFetcher::POST, 50 post_url, net::URLFetcher::POST,
47 new FeedbackUploaderDelegate( 51 new FeedbackUploaderDelegate(
48 data, 52 data,
49 base::Bind(&FeedbackUploaderChrome::UpdateUploadTimer, AsWeakPtr()), 53 base::Bind(&FeedbackUploaderChrome::UpdateUploadTimer, AsWeakPtr()),
50 base::Bind(&FeedbackUploaderChrome::RetryReport, AsWeakPtr()))); 54 base::Bind(&FeedbackUploaderChrome::RetryReport, AsWeakPtr())));
51 55
52 fetcher->SetUploadData(std::string(kProtoBufMimeType), data); 56 // Tell feedback server about the variation state of this install.
57 net::HttpRequestHeaders headers;
58 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders(
59 fetcher->GetOriginalURL(), context_->IsOffTheRecord(), false, &headers);
60 fetcher->SetExtraRequestHeaders(headers.ToString());
61
62 fetcher->SetUploadData(kProtoBufMimeType, data);
53 fetcher->SetRequestContext(context_->GetRequestContext()); 63 fetcher->SetRequestContext(context_->GetRequestContext());
54 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | 64 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES |
55 net::LOAD_DO_NOT_SEND_COOKIES); 65 net::LOAD_DO_NOT_SEND_COOKIES);
56 fetcher->Start(); 66 fetcher->Start();
57 } 67 }
58 68
59 } // namespace feedback 69 } // namespace feedback
OLDNEW
« no previous file with comments | « components/feedback/DEPS ('k') | components/feedback/feedback_uploader_chrome_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698