| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/copresence/copresence_manager_impl.h" | 5 #include "components/copresence/copresence_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "components/copresence/public/copresence_delegate.h" | 8 #include "components/copresence/public/copresence_delegate.h" |
| 9 #include "components/copresence/public/whispernet_client.h" | 9 #include "components/copresence/public/whispernet_client.h" |
| 10 #include "components/copresence/rpc/rpc_handler.h" | 10 #include "components/copresence/rpc/rpc_handler.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 void CopresenceManagerImpl::CompleteInitialization() { | 59 void CopresenceManagerImpl::CompleteInitialization() { |
| 60 if (pending_init_operations_) | 60 if (pending_init_operations_) |
| 61 return; | 61 return; |
| 62 | 62 |
| 63 DCHECK(rpc_handler_.get()); | 63 DCHECK(rpc_handler_.get()); |
| 64 if (!init_failed_) | 64 if (!init_failed_) |
| 65 rpc_handler_->ConnectToWhispernet(); | 65 rpc_handler_->ConnectToWhispernet(); |
| 66 | 66 |
| 67 for (std::vector<PendingRequest>::iterator request = | 67 for (PendingRequest& request : pending_requests_queue_) { |
| 68 pending_requests_queue_.begin(); | |
| 69 request != pending_requests_queue_.end(); | |
| 70 ++request) { | |
| 71 if (init_failed_) { | 68 if (init_failed_) { |
| 72 request->callback.Run(FAIL); | 69 request.callback.Run(FAIL); |
| 73 } else { | 70 } else { |
| 74 rpc_handler_->SendReportRequest( | 71 rpc_handler_->SendReportRequest( |
| 75 make_scoped_ptr(new copresence::ReportRequest(request->report)), | 72 make_scoped_ptr(new copresence::ReportRequest(request.report)), |
| 76 request->app_id, | 73 request.app_id, |
| 77 request->callback); | 74 request.callback); |
| 78 } | 75 } |
| 79 } | 76 } |
| 80 pending_requests_queue_.clear(); | 77 pending_requests_queue_.clear(); |
| 81 } | 78 } |
| 82 | 79 |
| 83 void CopresenceManagerImpl::InitStepComplete( | 80 void CopresenceManagerImpl::InitStepComplete( |
| 84 const std::string& step, bool success) { | 81 const std::string& step, bool success) { |
| 85 if (!success) { | 82 if (!success) { |
| 86 LOG(ERROR) << step << " failed!"; | 83 LOG(ERROR) << step << " failed!"; |
| 87 init_failed_ = true; | 84 init_failed_ = true; |
| 88 } | 85 } |
| 89 | 86 |
| 90 DVLOG(3) << "Init step: " << step << " complete."; | 87 DVLOG(3) << "Init step: " << step << " complete."; |
| 91 pending_init_operations_--; | 88 pending_init_operations_--; |
| 92 CompleteInitialization(); | 89 CompleteInitialization(); |
| 93 } | 90 } |
| 94 | 91 |
| 95 } // namespace copresence | 92 } // namespace copresence |
| OLD | NEW |