OLD | NEW |
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 Loading... |
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 |
OLD | NEW |