Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Side by Side Diff: components/feedback/feedback_uploader.cc

Issue 225183018: Move feedback files into src/components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix deps, merge gyp targets, sync with latest Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/feedback/feedback_uploader.h" 5 #include "components/feedback/feedback_uploader.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/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
11 #include "base/task_runner_util.h" 11 #include "base/task_runner_util.h"
12 #include "base/threading/sequenced_worker_pool.h" 12 #include "base/threading/sequenced_worker_pool.h"
13 #include "chrome/browser/feedback/feedback_report.h" 13 #include "components/feedback/feedback_report.h"
14 14
15 namespace feedback { 15 namespace feedback {
16 namespace { 16 namespace {
17 17
18 const char kFeedbackPostUrl[] = 18 const char kFeedbackPostUrl[] =
19 "https://www.google.com/tools/feedback/chrome/__submit"; 19 "https://www.google.com/tools/feedback/chrome/__submit";
20 20
21 const int64 kRetryDelayMinutes = 60; 21 const int64 kRetryDelayMinutes = 60;
22 22
23 const base::FilePath::CharType kFeedbackReportPath[] = 23 const base::FilePath::CharType kFeedbackReportPath[] =
24 FILE_PATH_LITERAL("Feedback Reports"); 24 FILE_PATH_LITERAL("Feedback Reports");
25 25
26 } // namespace 26 } // namespace
27 27
28 bool FeedbackUploader::ReportsUploadTimeComparator::operator()( 28 bool FeedbackUploader::ReportsUploadTimeComparator::operator()(
29 FeedbackReport* a, FeedbackReport* b) const { 29 FeedbackReport* a, FeedbackReport* b) const {
30 return a->upload_at() > b->upload_at(); 30 return a->upload_at() > b->upload_at();
31 } 31 }
32 32
33 FeedbackUploader::FeedbackUploader(const base::FilePath& path, 33 FeedbackUploader::FeedbackUploader(const base::FilePath& path,
34 base::SequencedWorkerPool* pool) 34 base::SequencedWorkerPool* pool)
35 : report_path_(path.Append(kFeedbackReportPath)), 35 : report_path_(path.Append(kFeedbackReportPath)),
36 retry_delay_(base::TimeDelta::FromMinutes(kRetryDelayMinutes)), 36 retry_delay_(base::TimeDelta::FromMinutes(kRetryDelayMinutes)),
37 url_(kFeedbackPostUrl), 37 url_(kFeedbackPostUrl),
38 pool_(pool) { 38 pool_(pool) {
39 dispatch_callback_ = base::Bind(&FeedbackUploader::DispatchReport, 39 dispatch_callback_ = base::Bind(&FeedbackUploader::DispatchReport,
40 AsWeakPtr()); 40 AsWeakPtr());
41 } 41 }
42 42
43 FeedbackUploader::FeedbackUploader(const base::FilePath& path,
44 base::SequencedWorkerPool* pool,
45 const std::string& url)
46 : report_path_(path.Append(kFeedbackReportPath)),
47 retry_delay_(base::TimeDelta::FromMinutes(kRetryDelayMinutes)),
48 url_(url),
49 pool_(pool) {
50 dispatch_callback_ = base::Bind(&FeedbackUploader::DispatchReport,
rkc 2014/04/28 22:41:32 Extract common functionality in the constructors t
achaulk 2014/04/30 17:12:34 Done.
51 AsWeakPtr());
52 }
53
43 FeedbackUploader::~FeedbackUploader() {} 54 FeedbackUploader::~FeedbackUploader() {}
44 55
45 void FeedbackUploader::QueueReport(const std::string& data) { 56 void FeedbackUploader::QueueReport(const std::string& data) {
46 QueueReportWithDelay(data, base::TimeDelta()); 57 QueueReportWithDelay(data, base::TimeDelta());
47 } 58 }
48 59
49 void FeedbackUploader::UpdateUploadTimer() { 60 void FeedbackUploader::UpdateUploadTimer() {
50 if (reports_queue_.empty()) 61 if (reports_queue_.empty())
51 return; 62 return;
52 63
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 98 }
88 99
89 void FeedbackUploader::setup_for_test( 100 void FeedbackUploader::setup_for_test(
90 const ReportDataCallback& dispatch_callback, 101 const ReportDataCallback& dispatch_callback,
91 const base::TimeDelta& retry_delay) { 102 const base::TimeDelta& retry_delay) {
92 dispatch_callback_ = dispatch_callback; 103 dispatch_callback_ = dispatch_callback;
93 retry_delay_ = retry_delay; 104 retry_delay_ = retry_delay;
94 } 105 }
95 106
96 } // namespace feedback 107 } // namespace feedback
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698