| 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 (PendingRequest& request : pending_requests_queue_) { | 67 // for (PendingRequest& request : pending_requests_queue_) { |
| 68 for (size_t i = 0; i < pending_requests_queue_.size(); ++i) { |
| 69 PendingRequest request = pending_requests_queue_[i]; |
| 68 if (init_failed_) { | 70 if (init_failed_) { |
| 69 request.callback.Run(FAIL); | 71 request.callback.Run(FAIL); |
| 70 } else { | 72 } else { |
| 71 rpc_handler_->SendReportRequest( | 73 rpc_handler_->SendReportRequest( |
| 72 make_scoped_ptr(new copresence::ReportRequest(request.report)), | 74 make_scoped_ptr(new copresence::ReportRequest(request.report)), |
| 73 request.app_id, | 75 request.app_id, |
| 74 request.callback); | 76 request.callback); |
| 75 } | 77 } |
| 76 } | 78 } |
| 77 pending_requests_queue_.clear(); | 79 pending_requests_queue_.clear(); |
| 78 } | 80 } |
| 79 | 81 |
| 80 void CopresenceManagerImpl::InitStepComplete( | 82 void CopresenceManagerImpl::InitStepComplete( |
| 81 const std::string& step, bool success) { | 83 const std::string& step, bool success) { |
| 82 if (!success) { | 84 if (!success) { |
| 83 LOG(ERROR) << step << " failed!"; | 85 LOG(ERROR) << step << " failed!"; |
| 84 init_failed_ = true; | 86 init_failed_ = true; |
| 85 } | 87 } |
| 86 | 88 |
| 87 DVLOG(3) << "Init step: " << step << " complete."; | 89 DVLOG(3) << "Init step: " << step << " complete."; |
| 88 pending_init_operations_--; | 90 pending_init_operations_--; |
| 89 CompleteInitialization(); | 91 CompleteInitialization(); |
| 90 } | 92 } |
| 91 | 93 |
| 92 } // namespace copresence | 94 } // namespace copresence |
| OLD | NEW |