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

Side by Side Diff: content/common/mojo/existing_thread_loader.cc

Issue 1856313002: mojo: Add ExistingThreadLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « content/common/mojo/existing_thread_loader.h ('k') | content/content_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/common/mojo/existing_thread_loader.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h"
11
12 namespace content {
13
14 ExistingThreadLoader::ExistingThreadLoader(
15 const ApplicationFactory& factory,
16 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
17 : factory_(factory), task_runner_(task_runner), weak_factory_(this) {}
18
19 ExistingThreadLoader::~ExistingThreadLoader() {}
20
21 void ExistingThreadLoader::Load(const std::string& name,
22 mojo::shell::mojom::ShellClientRequest request) {
23 task_runner_->PostTask(
24 FROM_HERE,
25 base::Bind(&ExistingThreadLoader::LoadOnTaskRunner,
26 weak_factory_.GetWeakPtr(), name, base::Passed(&request)));
27 }
28
29 void ExistingThreadLoader::LoadOnTaskRunner(
30 const std::string& name,
31 mojo::shell::mojom::ShellClientRequest request) {
32 if (!shell_client_) {
33 shell_client_ = factory_.Run();
34 factory_ = ApplicationFactory();
alokp 2016/04/05 15:33:55 what is the need for clearing the fatory_?
35 }
36
37 connections_.push_back(make_scoped_ptr(
38 new mojo::ShellConnection(shell_client_.get(), std::move(request))));
39 }
40
41 } // namespace content
OLDNEW
« no previous file with comments | « content/common/mojo/existing_thread_loader.h ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698