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

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

Issue 11360151: Move common cloud print methods from service/cloud_print to common/cloud_print. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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) 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/cloud_print_wipeout.h" 5 #include "chrome/service/cloud_print/cloud_print_wipeout.h"
6 6
7 #include "chrome/common/cloud_print/cloud_print_helpers.h"
7 #include "chrome/service/cloud_print/cloud_print_consts.h" 8 #include "chrome/service/cloud_print/cloud_print_consts.h"
8 #include "chrome/service/cloud_print/cloud_print_helpers.h" 9 #include "chrome/service/cloud_print/cloud_print_helpers.h"
msw 2012/11/17 00:22:30 Remove this unused include.
Chen Yu 2012/11/26 12:07:06 Done.
9 10
10 const int kMaxWipeoutAttempts = 3; 11 const int kMaxWipeoutAttempts = 3;
11 12
12 CloudPrintWipeout::CloudPrintWipeout(Client* client, 13 CloudPrintWipeout::CloudPrintWipeout(Client* client,
13 const GURL& cloud_print_server_url) 14 const GURL& cloud_print_server_url)
14 : client_(client), cloud_print_server_url_(cloud_print_server_url) { 15 : client_(client), cloud_print_server_url_(cloud_print_server_url) {
15 } 16 }
16 CloudPrintWipeout::~CloudPrintWipeout() { 17 CloudPrintWipeout::~CloudPrintWipeout() {
17 } 18 }
18 19
19 void CloudPrintWipeout::UnregisterPrinters( 20 void CloudPrintWipeout::UnregisterPrinters(
20 const std::string& auth_token, 21 const std::string& auth_token,
21 const std::list<std::string>& printer_ids) { 22 const std::list<std::string>& printer_ids) {
22 auth_token_ = auth_token; 23 auth_token_ = auth_token;
23 printer_ids_ = printer_ids; 24 printer_ids_ = printer_ids;
24 UnregisterNextPrinter(); 25 UnregisterNextPrinter();
25 } 26 }
26 27
27 void CloudPrintWipeout::UnregisterNextPrinter() { 28 void CloudPrintWipeout::UnregisterNextPrinter() {
28 if (printer_ids_.empty()) { 29 if (printer_ids_.empty()) {
29 client_->OnUnregisterPrintersComplete(); 30 client_->OnUnregisterPrintersComplete();
30 return; 31 return;
31 } 32 }
32 33
33 std::string printer_id = printer_ids_.front(); 34 std::string printer_id = printer_ids_.front();
34 printer_ids_.pop_front(); 35 printer_ids_.pop_front();
35 36
36 GURL url = CloudPrintHelpers::GetUrlForPrinterDelete(cloud_print_server_url_, 37 GURL url = cloud_print::GetUrlForPrinterDelete(cloud_print_server_url_,
msw 2012/11/17 00:22:30 ditto nit: put this file in the cloud_print namesp
Chen Yu 2012/11/26 12:07:06 Done.
37 printer_id, 38 printer_id,
38 "connector_disabled"); 39 "connector_disabled");
39 request_ = new CloudPrintURLFetcher; 40 request_ = new CloudPrintURLFetcher;
40 request_->StartGetRequest(url, this, kMaxWipeoutAttempts, std::string()); 41 request_->StartGetRequest(url, this, kMaxWipeoutAttempts, std::string());
41 } 42 }
42 43
43 CloudPrintURLFetcher::ResponseAction CloudPrintWipeout::HandleJSONData( 44 CloudPrintURLFetcher::ResponseAction CloudPrintWipeout::HandleJSONData(
44 const net::URLFetcher* source, 45 const net::URLFetcher* source,
45 const GURL& url, 46 const GURL& url,
46 base::DictionaryValue* json_data, 47 base::DictionaryValue* json_data,
47 bool succeeded) { 48 bool succeeded) {
48 // We don't care if delete was sucessful or not here. 49 // We don't care if delete was sucessful or not here.
49 UnregisterNextPrinter(); 50 UnregisterNextPrinter();
50 return CloudPrintURLFetcher::STOP_PROCESSING; 51 return CloudPrintURLFetcher::STOP_PROCESSING;
51 } 52 }
52 53
53 void CloudPrintWipeout::OnRequestGiveUp() { 54 void CloudPrintWipeout::OnRequestGiveUp() {
54 UnregisterNextPrinter(); 55 UnregisterNextPrinter();
55 } 56 }
56 57
57 CloudPrintURLFetcher::ResponseAction CloudPrintWipeout::OnRequestAuthError() { 58 CloudPrintURLFetcher::ResponseAction CloudPrintWipeout::OnRequestAuthError() {
58 // We can't recover from auth rrror. Report complition to stop service. 59 // We can't recover from auth rrror. Report complition to stop service.
59 client_->OnUnregisterPrintersComplete(); 60 client_->OnUnregisterPrintersComplete();
60 return CloudPrintURLFetcher::STOP_PROCESSING; 61 return CloudPrintURLFetcher::STOP_PROCESSING;
61 } 62 }
62 63
63 std::string CloudPrintWipeout::GetAuthHeader() { 64 std::string CloudPrintWipeout::GetAuthHeader() {
64 return CloudPrintHelpers::GetCloudPrintAuthHeader(auth_token_); 65 return cloud_print::GetCloudPrintAuthHeader(auth_token_);
65 } 66 }
66 67
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698