| OLD | NEW |
| 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 "cloud_print/gcp20/prototype/cloud_print_requester.h" | 5 #include "cloud_print/gcp20/prototype/cloud_print_requester.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 9 #include <limits> |
| 10 |
| 7 #include "base/bind.h" | 11 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 9 #include "base/md5.h" | 13 #include "base/md5.h" |
| 10 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 11 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
| 12 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 13 #include "cloud_print/gcp20/prototype/cloud_print_url_request_context_getter.h" | 17 #include "cloud_print/gcp20/prototype/cloud_print_url_request_context_getter.h" |
| 14 #include "google_apis/google_api_keys.h" | 18 #include "google_apis/google_api_keys.h" |
| 15 #include "net/base/escape.h" | 19 #include "net/base/escape.h" |
| 16 #include "net/base/mime_util.h" | 20 #include "net/base/mime_util.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 bool CloudPrintRequester::IsBusy() const { | 119 bool CloudPrintRequester::IsBusy() const { |
| 116 return request_ || gaia_; | 120 return request_ || gaia_; |
| 117 } | 121 } |
| 118 | 122 |
| 119 void CloudPrintRequester::StartRegistration(const std::string& proxy_id, | 123 void CloudPrintRequester::StartRegistration(const std::string& proxy_id, |
| 120 const std::string& device_name, | 124 const std::string& device_name, |
| 121 const std::string& user, | 125 const std::string& user, |
| 122 const LocalSettings& settings, | 126 const LocalSettings& settings, |
| 123 const std::string& cdd) { | 127 const std::string& cdd) { |
| 124 std::string mime_boundary; | 128 std::string mime_boundary; |
| 125 int r1 = base::RandInt(0, kint32max); | 129 int r1 = base::RandInt(0, std::numeric_limits<int32_t>::max()); |
| 126 int r2 = base::RandInt(0, kint32max); | 130 int r2 = base::RandInt(0, std::numeric_limits<int32_t>::max()); |
| 127 base::SStringPrintf(&mime_boundary, | 131 base::SStringPrintf(&mime_boundary, |
| 128 "---------------------------%08X%08X", r1, r2); | 132 "---------------------------%08X%08X", r1, r2); |
| 129 | 133 |
| 130 std::string data; | 134 std::string data; |
| 131 std::string data_mimetype; | 135 std::string data_mimetype; |
| 132 data_mimetype = "multipart/form-data; boundary=" + mime_boundary; | 136 data_mimetype = "multipart/form-data; boundary=" + mime_boundary; |
| 133 | 137 |
| 134 net::AddMultipartValueForUpload(kProxyIdValue, proxy_id, mime_boundary, | 138 net::AddMultipartValueForUpload(kProxyIdValue, proxy_id, mime_boundary, |
| 135 std::string(), &data); | 139 std::string(), &data); |
| 136 net::AddMultipartValueForUpload(kPrinterNameValue, device_name, mime_boundary, | 140 net::AddMultipartValueForUpload(kPrinterNameValue, device_name, mime_boundary, |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 delegate_->OnLocalSettingsReceived(state, settings); | 463 delegate_->OnLocalSettingsReceived(state, settings); |
| 460 } else { | 464 } else { |
| 461 delegate_->OnServerError(error_description); | 465 delegate_->OnServerError(error_description); |
| 462 } | 466 } |
| 463 } | 467 } |
| 464 | 468 |
| 465 void CloudPrintRequester::ParseLocalSettingUpdated( | 469 void CloudPrintRequester::ParseLocalSettingUpdated( |
| 466 const std::string& response) { | 470 const std::string& response) { |
| 467 delegate_->OnLocalSettingsUpdated(); | 471 delegate_->OnLocalSettingsUpdated(); |
| 468 } | 472 } |
| OLD | NEW |