OLD | NEW |
---|---|
(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 | |
OLD | NEW |