Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2119)

Unified Diff: components/copresence/copresence_manager.cc

Issue 441103002: Tests for the Copresence API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@api
Patch Set: Moving initialization to SetUpOnMainThread() Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/copresence/copresence_manager.cc
diff --git a/components/copresence/copresence_manager.cc b/components/copresence/copresence_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6fd7e5fd0cda2247d41c1316a73895f1d139a9a5
--- /dev/null
+++ b/components/copresence/copresence_manager.cc
@@ -0,0 +1,39 @@
+// Copyright 2014 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 "components/copresence/public/copresence_manager.h"
+
+#include "base/bind.h"
+#include "components/copresence/copresence_manager_impl.h"
+#include "components/copresence/rpc/rpc_handler.h"
+
+namespace copresence {
+
+// static
+scoped_ptr<CopresenceManager> CopresenceManager::Create(
+ CopresenceManagerDelegate* delegate) {
+ CopresenceManagerImpl* manager = new CopresenceManagerImpl(delegate);
+
+ manager->pending_init_operations_++;
+ manager->rpc_handler_.reset(new RpcHandler(delegate));
+ manager->rpc_handler_->Initialize(
+ base::Bind(&CopresenceManagerImpl::InitStepComplete,
+ // This is safe because the manager owns the RpcHandler.
+ base::Unretained(manager),
+ "Copresence device registration"));
+
+ manager->pending_init_operations_++;
+ DCHECK(delegate->GetWhispernetClient());
+ delegate->GetWhispernetClient()->Initialize(
+ base::Bind(&CopresenceManagerImpl::InitStepComplete,
+ // We cannot cancel WhispernetClient initialization.
+ // TODO(ckehoe): Get rid of this.
+ manager->AsWeakPtr(),
+ "Whispernet proxy initialization"));
+
+ return make_scoped_ptr<CopresenceManager>(manager);
+}
+
+} // namespace copresence
+

Powered by Google App Engine
This is Rietveld 408576698