Index: content/common/mojo/existing_thread_loader.cc |
diff --git a/content/common/mojo/existing_thread_loader.cc b/content/common/mojo/existing_thread_loader.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cea026a5b8d4e8cde0187c9082a3ac20139f58a7 |
--- /dev/null |
+++ b/content/common/mojo/existing_thread_loader.cc |
@@ -0,0 +1,41 @@ |
+// Copyright 2016 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 "content/common/mojo/existing_thread_loader.h" |
+ |
+#include "base/bind.h" |
+#include "base/bind_helpers.h" |
+#include "base/location.h" |
+#include "base/single_thread_task_runner.h" |
+ |
+namespace content { |
+ |
+ExistingThreadLoader::ExistingThreadLoader( |
+ const ApplicationFactory& factory, |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
+ : factory_(factory), task_runner_(task_runner), weak_factory_(this) {} |
+ |
+ExistingThreadLoader::~ExistingThreadLoader() {} |
+ |
+void ExistingThreadLoader::Load(const std::string& name, |
+ mojo::shell::mojom::ShellClientRequest request) { |
+ task_runner_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&ExistingThreadLoader::LoadOnTaskRunner, |
+ weak_factory_.GetWeakPtr(), name, base::Passed(&request))); |
+} |
+ |
+void ExistingThreadLoader::LoadOnTaskRunner( |
+ const std::string& name, |
+ mojo::shell::mojom::ShellClientRequest request) { |
+ if (!shell_client_) { |
+ shell_client_ = factory_.Run(); |
+ factory_ = ApplicationFactory(); |
alokp
2016/04/05 15:33:55
what is the need for clearing the fatory_?
|
+ } |
+ |
+ connections_.push_back(make_scoped_ptr( |
+ new mojo::ShellConnection(shell_client_.get(), std::move(request)))); |
+} |
+ |
+} // namespace content |