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

Side by Side Diff: mojo/shell/network_application_loader.cc

Issue 775343004: Move //mojo/shell to //shell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/shell/network_application_loader.h"
6
7 #include "base/base_paths.h"
8 #include "base/files/file_path.h"
9 #include "base/path_service.h"
10 #include "mojo/public/cpp/application/application_connection.h"
11 #include "mojo/public/cpp/application/application_delegate.h"
12 #include "mojo/public/cpp/application/application_impl.h"
13 #include "mojo/services/network/network_service_impl.h"
14
15 namespace {
16 base::FilePath GetBasePath() {
17 base::FilePath path;
18 CHECK(PathService::Get(base::DIR_TEMP, &path));
19 return path.Append(FILE_PATH_LITERAL("network_service"));
20 }
21 }
22
23 namespace mojo {
24 namespace shell {
25
26 NetworkApplicationLoader::NetworkApplicationLoader() {
27 }
28
29 NetworkApplicationLoader::~NetworkApplicationLoader() {
30 }
31
32 void NetworkApplicationLoader::Load(ApplicationManager* manager,
33 const GURL& url,
34 ScopedMessagePipeHandle shell_handle,
35 LoadCallback callback) {
36 DCHECK(shell_handle.is_valid());
37 uintptr_t key = reinterpret_cast<uintptr_t>(manager);
38 if (apps_.find(key) == apps_.end()) {
39 scoped_ptr<ApplicationImpl> app(
40 new ApplicationImpl(this, shell_handle.Pass()));
41 apps_.add(key, app.Pass());
42 }
43 }
44
45 void NetworkApplicationLoader::OnApplicationError(ApplicationManager* manager,
46 const GURL& url) {
47 apps_.erase(reinterpret_cast<uintptr_t>(manager));
48 }
49
50 void NetworkApplicationLoader::Initialize(ApplicationImpl* app) {
51 // The context must be created on the same thread as the network service.
52 context_.reset(new NetworkContext(GetBasePath()));
53 }
54
55 bool NetworkApplicationLoader::ConfigureIncomingConnection(
56 ApplicationConnection* connection) {
57 connection->AddService(this);
58 return true;
59 }
60
61 void NetworkApplicationLoader::Create(
62 ApplicationConnection* connection,
63 InterfaceRequest<NetworkService> request) {
64 BindToRequest(new NetworkServiceImpl(connection, context_.get()), &request);
65 }
66
67 } // namespace shell
68 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/network_application_loader.h ('k') | mojo/shell/out_of_process_dynamic_service_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698