-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeedback_uploader_http.cc
33 lines (27 loc) · 1.05 KB
/
feedback_uploader_http.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "feedback/feedback_uploader_http.h"
#include <brillo/http/http_utils.h>
#include <brillo/mime_utils.h>
namespace feedback {
FeedbackUploaderHttp::FeedbackUploaderHttp(
const base::FilePath& path,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
const std::string& url)
: FeedbackUploader(path, task_runner, url) {}
void FeedbackUploaderHttp::DispatchReport(const std::string& data) {
brillo::ErrorPtr error;
auto response = brillo::http::PostBinaryAndBlock(
url_, data.data(), data.size(), brillo::mime::application::kProtobuf, {},
brillo::http::Transport::CreateDefault(), &error);
if (response) {
LOG(INFO) << "Sending feedback: successful";
UpdateUploadTimer();
} else {
LOG(WARNING) << "Sending feedback: failed with error "
<< error->GetMessage() << ", retrying";
RetryReport(data);
}
}
} // namespace feedback