| OLD | NEW |
| 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_proxy_backend.h" | 5 #include "chrome/service/cloud_print/cloud_print_proxy_backend.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 179 } |
| 180 | 180 |
| 181 CloudPrintProxyBackend::~CloudPrintProxyBackend() { DCHECK(!core_.get()); } | 181 CloudPrintProxyBackend::~CloudPrintProxyBackend() { DCHECK(!core_.get()); } |
| 182 | 182 |
| 183 bool CloudPrintProxyBackend::InitializeWithToken( | 183 bool CloudPrintProxyBackend::InitializeWithToken( |
| 184 const std::string& cloud_print_token) { | 184 const std::string& cloud_print_token) { |
| 185 if (!core_thread_.Start()) | 185 if (!core_thread_.Start()) |
| 186 return false; | 186 return false; |
| 187 PostCoreTask(FROM_HERE, | 187 PostCoreTask(FROM_HERE, |
| 188 base::Bind(&CloudPrintProxyBackend::Core::DoInitializeWithToken, | 188 base::Bind(&CloudPrintProxyBackend::Core::DoInitializeWithToken, |
| 189 core_.get(), cloud_print_token)); | 189 core_, cloud_print_token)); |
| 190 return true; | 190 return true; |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool CloudPrintProxyBackend::InitializeWithRobotToken( | 193 bool CloudPrintProxyBackend::InitializeWithRobotToken( |
| 194 const std::string& robot_oauth_refresh_token, | 194 const std::string& robot_oauth_refresh_token, |
| 195 const std::string& robot_email) { | 195 const std::string& robot_email) { |
| 196 if (!core_thread_.Start()) | 196 if (!core_thread_.Start()) |
| 197 return false; | 197 return false; |
| 198 PostCoreTask( | 198 PostCoreTask( |
| 199 FROM_HERE, | 199 FROM_HERE, |
| 200 base::Bind(&CloudPrintProxyBackend::Core::DoInitializeWithRobotToken, | 200 base::Bind(&CloudPrintProxyBackend::Core::DoInitializeWithRobotToken, |
| 201 core_.get(), robot_oauth_refresh_token, robot_email)); | 201 core_, robot_oauth_refresh_token, robot_email)); |
| 202 return true; | 202 return true; |
| 203 } | 203 } |
| 204 | 204 |
| 205 bool CloudPrintProxyBackend::InitializeWithRobotAuthCode( | 205 bool CloudPrintProxyBackend::InitializeWithRobotAuthCode( |
| 206 const std::string& robot_oauth_auth_code, | 206 const std::string& robot_oauth_auth_code, |
| 207 const std::string& robot_email) { | 207 const std::string& robot_email) { |
| 208 if (!core_thread_.Start()) | 208 if (!core_thread_.Start()) |
| 209 return false; | 209 return false; |
| 210 PostCoreTask( | 210 PostCoreTask( |
| 211 FROM_HERE, | 211 FROM_HERE, |
| 212 base::Bind(&CloudPrintProxyBackend::Core::DoInitializeWithRobotAuthCode, | 212 base::Bind(&CloudPrintProxyBackend::Core::DoInitializeWithRobotAuthCode, |
| 213 core_.get(), robot_oauth_auth_code, robot_email)); | 213 core_, robot_oauth_auth_code, robot_email)); |
| 214 return true; | 214 return true; |
| 215 } | 215 } |
| 216 | 216 |
| 217 void CloudPrintProxyBackend::Shutdown() { | 217 void CloudPrintProxyBackend::Shutdown() { |
| 218 PostCoreTask(FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::DoShutdown, | 218 PostCoreTask(FROM_HERE, base::Bind(&CloudPrintProxyBackend::Core::DoShutdown, |
| 219 core_.get())); | 219 core_)); |
| 220 core_thread_.Stop(); | 220 core_thread_.Stop(); |
| 221 core_ = nullptr; // Releases reference to |core_|. | 221 core_ = nullptr; // Releases reference to |core_|. |
| 222 } | 222 } |
| 223 | 223 |
| 224 void CloudPrintProxyBackend::UnregisterPrinters() { | 224 void CloudPrintProxyBackend::UnregisterPrinters() { |
| 225 PostCoreTask(FROM_HERE, | 225 PostCoreTask(FROM_HERE, |
| 226 base::Bind(&CloudPrintProxyBackend::Core::DoUnregisterPrinters, | 226 base::Bind(&CloudPrintProxyBackend::Core::DoUnregisterPrinters, |
| 227 core_.get())); | 227 core_)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 bool CloudPrintProxyBackend::PostCoreTask( | 230 bool CloudPrintProxyBackend::PostCoreTask( |
| 231 const tracked_objects::Location& from_here, | 231 const tracked_objects::Location& from_here, |
| 232 const base::Closure& task) { | 232 const base::Closure& task) { |
| 233 return core_thread_.task_runner()->PostTask(from_here, task); | 233 return core_thread_.task_runner()->PostTask(from_here, task); |
| 234 } | 234 } |
| 235 | 235 |
| 236 CloudPrintProxyBackend::Core::Core( | 236 CloudPrintProxyBackend::Core::Core( |
| 237 CloudPrintProxyBackend* backend, | 237 CloudPrintProxyBackend* backend, |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 HandlePrinterNotification(notification.data); | 578 HandlePrinterNotification(notification.data); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void CloudPrintProxyBackend::Core::OnPingResponse() { | 581 void CloudPrintProxyBackend::Core::OnPingResponse() { |
| 582 UMA_HISTOGRAM_COUNTS_100("CloudPrint.XmppPingTry", pending_xmpp_pings_); | 582 UMA_HISTOGRAM_COUNTS_100("CloudPrint.XmppPingTry", pending_xmpp_pings_); |
| 583 pending_xmpp_pings_ = 0; | 583 pending_xmpp_pings_ = 0; |
| 584 VLOG(1) << "CP_CONNECTOR: Ping response received."; | 584 VLOG(1) << "CP_CONNECTOR: Ping response received."; |
| 585 } | 585 } |
| 586 | 586 |
| 587 } // namespace cloud_print | 587 } // namespace cloud_print |
| OLD | NEW |