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 "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 const char kProtoBufMimeType[] = "application/x-protobuf"; | 26 const char kProtoBufMimeType[] = "application/x-protobuf"; |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 FeedbackUploaderChrome::FeedbackUploaderChrome( | 30 FeedbackUploaderChrome::FeedbackUploaderChrome( |
31 content::BrowserContext* context) | 31 content::BrowserContext* context) |
32 : FeedbackUploader(context ? context->GetPath() : base::FilePath(), | 32 : FeedbackUploader(context ? context->GetPath() : base::FilePath(), |
33 BrowserThread::GetBlockingPool()), | 33 BrowserThread::GetBlockingPool()), |
34 context_(context) { | 34 context_(context) { |
35 CHECK(context_); | 35 CHECK(context_); |
36 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kFeedbackServer)) | 36 const base::CommandLine& command_line = |
37 url_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 37 *base::CommandLine::ForCurrentProcess(); |
38 switches::kFeedbackServer); | 38 if (command_line.HasSwitch(switches::kFeedbackServer)) |
| 39 url_ = command_line.GetSwitchValueASCII(switches::kFeedbackServer); |
39 } | 40 } |
40 | 41 |
41 void FeedbackUploaderChrome::DispatchReport(const std::string& data) { | 42 void FeedbackUploaderChrome::DispatchReport(const std::string& data) { |
42 GURL post_url(url_); | 43 GURL post_url(url_); |
43 | 44 |
44 net::URLFetcher* fetcher = net::URLFetcher::Create( | 45 net::URLFetcher* fetcher = net::URLFetcher::Create( |
45 post_url, net::URLFetcher::POST, | 46 post_url, net::URLFetcher::POST, |
46 new FeedbackUploaderDelegate( | 47 new FeedbackUploaderDelegate( |
47 data, | 48 data, |
48 base::Bind(&FeedbackUploaderChrome::UpdateUploadTimer, AsWeakPtr()), | 49 base::Bind(&FeedbackUploaderChrome::UpdateUploadTimer, AsWeakPtr()), |
49 base::Bind(&FeedbackUploaderChrome::RetryReport, AsWeakPtr()))); | 50 base::Bind(&FeedbackUploaderChrome::RetryReport, AsWeakPtr()))); |
50 | 51 |
51 fetcher->SetUploadData(std::string(kProtoBufMimeType), data); | 52 fetcher->SetUploadData(std::string(kProtoBufMimeType), data); |
52 fetcher->SetRequestContext(context_->GetRequestContext()); | 53 fetcher->SetRequestContext(context_->GetRequestContext()); |
53 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 54 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
54 net::LOAD_DO_NOT_SEND_COOKIES); | 55 net::LOAD_DO_NOT_SEND_COOKIES); |
55 fetcher->Start(); | 56 fetcher->Start(); |
56 } | 57 } |
57 | 58 |
58 } // namespace feedback | 59 } // namespace feedback |
OLD | NEW |