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

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

Issue 5276007: Implement exponential back-off mechanism. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pull latest to merge Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/common/net/http_return.h" 10 #include "chrome/common/net/http_return.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 last_job_details_.Clear(); 55 last_job_details_.Clear();
56 last_job_details_.status = cloud_print::PRINT_JOB_STATUS_COMPLETED; 56 last_job_details_.status = cloud_print::PRINT_JOB_STATUS_COMPLETED;
57 need_update = true; 57 need_update = true;
58 } 58 }
59 } 59 }
60 if (need_update) { 60 if (need_update) {
61 request_ = new CloudPrintURLFetcher; 61 request_ = new CloudPrintURLFetcher;
62 request_->StartGetRequest( 62 request_->StartGetRequest(
63 CloudPrintHelpers::GetUrlForJobStatusUpdate( 63 CloudPrintHelpers::GetUrlForJobStatusUpdate(
64 cloud_print_server_url_, job_id_, last_job_details_), 64 cloud_print_server_url_, job_id_, last_job_details_),
65 this, auth_token_, kCloudPrintAPIRetryPolicy); 65 this, auth_token_, kCloudPrintAPIMaxRetryCount);
66 } 66 }
67 } 67 }
68 } 68 }
69 69
70 void JobStatusUpdater::Stop() { 70 void JobStatusUpdater::Stop() {
71 request_ = NULL; 71 request_ = NULL;
72 DCHECK(delegate_); 72 DCHECK(delegate_);
73 stopped_ = true; 73 stopped_ = true;
74 delegate_->OnJobCompleted(this); 74 delegate_->OnJobCompleted(this);
75 } 75 }
76 76
77 // CloudPrintURLFetcher::Delegate implementation. 77 // CloudPrintURLFetcher::Delegate implementation.
78 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData( 78 CloudPrintURLFetcher::ResponseAction JobStatusUpdater::HandleJSONData(
79 const URLFetcher* source, 79 const URLFetcher* source,
80 const GURL& url, 80 const GURL& url,
81 DictionaryValue* json_data, 81 DictionaryValue* json_data,
82 bool succeeded) { 82 bool succeeded) {
83 if (last_job_details_.status == cloud_print::PRINT_JOB_STATUS_COMPLETED) { 83 if (last_job_details_.status == cloud_print::PRINT_JOB_STATUS_COMPLETED) {
84 MessageLoop::current()->PostTask( 84 MessageLoop::current()->PostTask(
85 FROM_HERE, NewRunnableMethod(this, &JobStatusUpdater::Stop)); 85 FROM_HERE, NewRunnableMethod(this, &JobStatusUpdater::Stop));
86 } 86 }
87 return CloudPrintURLFetcher::STOP_PROCESSING; 87 return CloudPrintURLFetcher::STOP_PROCESSING;
88 } 88 }
89 89
90 void JobStatusUpdater::OnRequestAuthError() { 90 void JobStatusUpdater::OnRequestAuthError() {
91 if (delegate_) 91 if (delegate_)
92 delegate_->OnAuthError(); 92 delegate_->OnAuthError();
93 } 93 }
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc ('k') | chrome/service/cloud_print/printer_job_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698