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
3 // found in the LICENSE file.
5 #include "components/feedback/feedback_uploader_chrome.h"
7 #include "base/callback.h"
8 #include "base/command_line.h"
9 #include "base/files/file_path.h"
10 #include "base/task_runner_util.h"
11 #include "base/threading/sequenced_worker_pool.h"
12 #include "components/feedback/feedback_report.h"
13 #include "components/feedback/feedback_switches.h"
14 #include "components/feedback/feedback_uploader_delegate.h"
15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "net/base/load_flags.h"
18 #include "net/url_request/url_fetcher.h"
21 using content::BrowserThread
;
26 const char kProtoBufMimeType
[] = "application/x-protobuf";
30 FeedbackUploaderChrome::FeedbackUploaderChrome(
31 content::BrowserContext
* context
)
32 : FeedbackUploader(context
? context
->GetPath() : base::FilePath(),
33 BrowserThread::GetBlockingPool()),
36 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kFeedbackServer
))
37 url_
= CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
38 switches::kFeedbackServer
);
41 void FeedbackUploaderChrome::DispatchReport(const std::string
& data
) {
44 net::URLFetcher
* fetcher
= net::URLFetcher::Create(
45 post_url
, net::URLFetcher::POST
,
46 new FeedbackUploaderDelegate(
48 base::Bind(&FeedbackUploaderChrome::UpdateUploadTimer
, AsWeakPtr()),
49 base::Bind(&FeedbackUploaderChrome::RetryReport
, AsWeakPtr())));
51 fetcher
->SetUploadData(std::string(kProtoBufMimeType
), data
);
52 fetcher
->SetRequestContext(context_
->GetRequestContext());
53 fetcher
->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES
|
54 net::LOAD_DO_NOT_SEND_COOKIES
);
58 } // namespace feedback