blob: bac219709968100ae25af83671e9c062ddedf513 (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright (c) 2012 The Chromium 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 "chrome/service/cloud_print/cloud_print_wipeout.h"
#include "chrome/common/cloud_print/cloud_print_constants.h"
#include "chrome/common/cloud_print/cloud_print_helpers.h"
const int kMaxWipeoutAttempts = 3;
namespace cloud_print {
CloudPrintWipeout::CloudPrintWipeout(Client* client,
const GURL& cloud_print_server_url)
: client_(client), cloud_print_server_url_(cloud_print_server_url) {
}
CloudPrintWipeout::~CloudPrintWipeout() {
}
void CloudPrintWipeout::UnregisterPrinters(
const std::string& auth_token,
const std::list<std::string>& printer_ids) {
auth_token_ = auth_token;
printer_ids_ = printer_ids;
UnregisterNextPrinter();
}
void CloudPrintWipeout::UnregisterNextPrinter() {
if (printer_ids_.empty()) {
client_->OnUnregisterPrintersComplete();
return;
}
std::string printer_id = printer_ids_.front();
printer_ids_.pop_front();
GURL url = GetUrlForPrinterDelete(cloud_print_server_url_,
printer_id,
"connector_disabled");
request_ = CloudPrintURLFetcher::Create();
request_->StartGetRequest(CloudPrintURLFetcher::REQUEST_UNREGISTER,
url, this, kMaxWipeoutAttempts, std::string());
}
CloudPrintURLFetcher::ResponseAction CloudPrintWipeout::HandleJSONData(
const net::URLFetcher* source,
const GURL& url,
base::DictionaryValue* json_data,
bool succeeded) {
// We don't care if delete was successful or not here.
UnregisterNextPrinter();
return CloudPrintURLFetcher::STOP_PROCESSING;
}
void CloudPrintWipeout::OnRequestGiveUp() {
UnregisterNextPrinter();
}
CloudPrintURLFetcher::ResponseAction CloudPrintWipeout::OnRequestAuthError() {
// We can't recover from auth error. Report completion to stop service.
client_->OnUnregisterPrintersComplete();
return CloudPrintURLFetcher::STOP_PROCESSING;
}
std::string CloudPrintWipeout::GetAuthHeader() {
return GetCloudPrintAuthHeader(auth_token_);
}
} // namespace cloud_print
|