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

Side by Side Diff: chrome/service/cloud_print/job_status_updater.cc

Issue 2888763004: Network traffic annotation added to CloudPrintUrlFetcher. (Closed)
Patch Set: nits Created 3 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/service/cloud_print/job_status_updater.h" 5 #include "chrome/service/cloud_print/job_status_updater.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace { 22 namespace {
23 23
24 bool IsTerminalJobState(PrintJobStatus status) { 24 bool IsTerminalJobState(PrintJobStatus status) {
25 return status == PRINT_JOB_STATUS_ERROR || 25 return status == PRINT_JOB_STATUS_ERROR ||
26 status == PRINT_JOB_STATUS_COMPLETED; 26 status == PRINT_JOB_STATUS_COMPLETED;
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 JobStatusUpdater::JobStatusUpdater(const std::string& printer_name, 31 JobStatusUpdater::JobStatusUpdater(
32 const std::string& job_id, 32 const std::string& printer_name,
33 PlatformJobId local_job_id, 33 const std::string& job_id,
34 const GURL& cloud_print_server_url, 34 PlatformJobId local_job_id,
35 PrintSystem* print_system, 35 const GURL& cloud_print_server_url,
36 Delegate* delegate) 36 PrintSystem* print_system,
37 Delegate* delegate,
38 const net::PartialNetworkTrafficAnnotationTag& partial_traffic_annotation)
37 : start_time_(base::Time::Now()), 39 : start_time_(base::Time::Now()),
38 printer_name_(printer_name), 40 printer_name_(printer_name),
39 job_id_(job_id), 41 job_id_(job_id),
40 local_job_id_(local_job_id), 42 local_job_id_(local_job_id),
41 cloud_print_server_url_(cloud_print_server_url), 43 cloud_print_server_url_(cloud_print_server_url),
42 print_system_(print_system), 44 print_system_(print_system),
43 delegate_(delegate), 45 delegate_(delegate),
44 stopped_(false) { 46 stopped_(false),
47 partial_traffic_annotation_(partial_traffic_annotation) {
45 DCHECK(delegate_); 48 DCHECK(delegate_);
46 } 49 }
47 50
48 // Start checking the status of the local print job. 51 // Start checking the status of the local print job.
49 void JobStatusUpdater::UpdateStatus() { 52 void JobStatusUpdater::UpdateStatus() {
50 // It does not matter if we had already sent out an update and are waiting for 53 // It does not matter if we had already sent out an update and are waiting for
51 // a response. This is a new update and we will simply cancel the old request 54 // a response. This is a new update and we will simply cancel the old request
52 // and send a new one. 55 // and send a new one.
53 if (!stopped_) { 56 if (!stopped_) {
54 bool need_update = false; 57 bool need_update = false;
(...skipping 15 matching lines...) Expand all
70 // longer exists in the OS queue. We are going to assume it is done in 73 // longer exists in the OS queue. We are going to assume it is done in
71 // this case. 74 // this case.
72 last_job_details_.Clear(); 75 last_job_details_.Clear();
73 last_job_details_.status = PRINT_JOB_STATUS_COMPLETED; 76 last_job_details_.status = PRINT_JOB_STATUS_COMPLETED;
74 need_update = true; 77 need_update = true;
75 } 78 }
76 UMA_HISTOGRAM_ENUMERATION("CloudPrint.NativeJobStatus", 79 UMA_HISTOGRAM_ENUMERATION("CloudPrint.NativeJobStatus",
77 last_job_details_.status, PRINT_JOB_STATUS_MAX); 80 last_job_details_.status, PRINT_JOB_STATUS_MAX);
78 } 81 }
79 if (need_update) { 82 if (need_update) {
80 request_ = CloudPrintURLFetcher::Create(); 83 request_ = CloudPrintURLFetcher::Create(partial_traffic_annotation_);
81 request_->StartGetRequest( 84 request_->StartGetRequest(
82 CloudPrintURLFetcher::REQUEST_UPDATE_JOB, 85 CloudPrintURLFetcher::REQUEST_UPDATE_JOB,
83 GetUrlForJobStatusUpdate( 86 GetUrlForJobStatusUpdate(
84 cloud_print_server_url_, job_id_, last_job_details_), 87 cloud_print_server_url_, job_id_, last_job_details_),
85 this, 88 this,
86 kCloudPrintAPIMaxRetryCount, 89 kCloudPrintAPIMaxRetryCount,
87 std::string()); 90 std::string());
88 } 91 }
89 } 92 }
90 } 93 }
(...skipping 28 matching lines...) Expand all
119 return CloudPrintURLFetcher::STOP_PROCESSING; 122 return CloudPrintURLFetcher::STOP_PROCESSING;
120 } 123 }
121 124
122 std::string JobStatusUpdater::GetAuthHeader() { 125 std::string JobStatusUpdater::GetAuthHeader() {
123 return GetCloudPrintAuthHeaderFromStore(); 126 return GetCloudPrintAuthHeaderFromStore();
124 } 127 }
125 128
126 JobStatusUpdater::~JobStatusUpdater() {} 129 JobStatusUpdater::~JobStatusUpdater() {}
127 130
128 } // namespace cloud_print 131 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/job_status_updater.h ('k') | chrome/service/cloud_print/printer_job_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698