| 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> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
| 13 #include "base/threading/sequenced_worker_pool.h" | |
| 14 #include "components/data_use_measurement/core/data_use_user_data.h" | 13 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 15 #include "components/feedback/feedback_report.h" | 14 #include "components/feedback/feedback_report.h" |
| 16 #include "components/feedback/feedback_switches.h" | 15 #include "components/feedback/feedback_switches.h" |
| 17 #include "components/feedback/feedback_uploader_delegate.h" | 16 #include "components/feedback/feedback_uploader_delegate.h" |
| 18 #include "components/variations/net/variations_http_headers.h" | 17 #include "components/variations/net/variations_http_headers.h" |
| 19 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/browser_thread.h" | |
| 21 #include "content/public/browser/storage_partition.h" | 19 #include "content/public/browser/storage_partition.h" |
| 22 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
| 23 #include "net/traffic_annotation/network_traffic_annotation.h" | 21 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 24 #include "net/url_request/url_fetcher.h" | 22 #include "net/url_request/url_fetcher.h" |
| 25 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 26 | 24 |
| 27 using content::BrowserThread; | |
| 28 | |
| 29 namespace feedback { | 25 namespace feedback { |
| 30 namespace { | 26 namespace { |
| 31 | 27 |
| 32 const char kProtoBufMimeType[] = "application/x-protobuf"; | 28 const char kProtoBufMimeType[] = "application/x-protobuf"; |
| 33 | 29 |
| 34 } // namespace | 30 } // namespace |
| 35 | 31 |
| 36 FeedbackUploaderChrome::FeedbackUploaderChrome( | 32 FeedbackUploaderChrome::FeedbackUploaderChrome(content::BrowserContext* context) |
| 37 content::BrowserContext* context) | 33 : FeedbackUploader(context ? context->GetPath() : base::FilePath()), |
| 38 : FeedbackUploader(context ? context->GetPath() : base::FilePath(), | |
| 39 BrowserThread::GetBlockingPool()), | |
| 40 context_(context) { | 34 context_(context) { |
| 41 CHECK(context_); | 35 CHECK(context_); |
| 42 const base::CommandLine& command_line = | 36 const base::CommandLine& command_line = |
| 43 *base::CommandLine::ForCurrentProcess(); | 37 *base::CommandLine::ForCurrentProcess(); |
| 44 if (command_line.HasSwitch(switches::kFeedbackServer)) | 38 if (command_line.HasSwitch(switches::kFeedbackServer)) |
| 45 url_ = command_line.GetSwitchValueASCII(switches::kFeedbackServer); | 39 url_ = command_line.GetSwitchValueASCII(switches::kFeedbackServer); |
| 46 } | 40 } |
| 47 | 41 |
| 48 void FeedbackUploaderChrome::DispatchReport(const std::string& data) { | 42 void FeedbackUploaderChrome::DispatchReport(const std::string& data) { |
| 49 GURL post_url(url_); | 43 GURL post_url(url_); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 fetcher->SetUploadData(kProtoBufMimeType, data); | 97 fetcher->SetUploadData(kProtoBufMimeType, data); |
| 104 fetcher->SetRequestContext( | 98 fetcher->SetRequestContext( |
| 105 content::BrowserContext::GetDefaultStoragePartition(context_)-> | 99 content::BrowserContext::GetDefaultStoragePartition(context_)-> |
| 106 GetURLRequestContext()); | 100 GetURLRequestContext()); |
| 107 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 101 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
| 108 net::LOAD_DO_NOT_SEND_COOKIES); | 102 net::LOAD_DO_NOT_SEND_COOKIES); |
| 109 fetcher->Start(); | 103 fetcher->Start(); |
| 110 } | 104 } |
| 111 | 105 |
| 112 } // namespace feedback | 106 } // namespace feedback |
| OLD | NEW |