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

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

Issue 395163002: Bundle the network service in the shell on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « mojo/shell/network_service_loader.h ('k') | mojo/shell/profile_service_loader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/shell/profile_service_loader.h" 5 #include "mojo/shell/network_service_loader.h"
6 6
7 #include "base/base_paths.h"
8 #include "base/files/file_path.h"
9 #include "base/path_service.h"
7 #include "mojo/public/cpp/application/application_connection.h" 10 #include "mojo/public/cpp/application/application_connection.h"
8 #include "mojo/public/cpp/application/application_delegate.h" 11 #include "mojo/public/cpp/application/application_delegate.h"
9 #include "mojo/public/cpp/application/application_impl.h" 12 #include "mojo/public/cpp/application/application_impl.h"
10 #include "mojo/services/profile/profile_service_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 }
11 22
12 namespace mojo { 23 namespace mojo {
13 namespace shell { 24 namespace shell {
14 25
15 ProfileServiceLoader::ProfileServiceLoader() { 26 NetworkServiceLoader::NetworkServiceLoader() {
16 } 27 }
17 28
18 ProfileServiceLoader::~ProfileServiceLoader() { 29 NetworkServiceLoader::~NetworkServiceLoader() {
19 } 30 }
20 31
21 void ProfileServiceLoader::LoadService( 32 void NetworkServiceLoader::LoadService(
22 ServiceManager* manager, 33 ServiceManager* manager,
23 const GURL& url, 34 const GURL& url,
24 ScopedMessagePipeHandle shell_handle) { 35 ScopedMessagePipeHandle shell_handle) {
25 uintptr_t key = reinterpret_cast<uintptr_t>(manager); 36 uintptr_t key = reinterpret_cast<uintptr_t>(manager);
26 if (apps_.find(key) == apps_.end()) { 37 if (apps_.find(key) == apps_.end()) {
27 scoped_ptr<ApplicationImpl> app( 38 scoped_ptr<ApplicationImpl> app(
28 new ApplicationImpl(this, shell_handle.Pass())); 39 new ApplicationImpl(this, shell_handle.Pass()));
29 apps_.add(key, app.Pass()); 40 apps_.add(key, app.Pass());
30 } 41 }
31 } 42 }
32 43
33 void ProfileServiceLoader::OnServiceError(ServiceManager* manager, 44 void NetworkServiceLoader::OnServiceError(ServiceManager* manager,
34 const GURL& url) { 45 const GURL& url) {
35 apps_.erase(reinterpret_cast<uintptr_t>(manager)); 46 apps_.erase(reinterpret_cast<uintptr_t>(manager));
36 } 47 }
37 48
38 bool ProfileServiceLoader::ConfigureIncomingConnection( 49 void NetworkServiceLoader::Initialize(ApplicationImpl* app) {
50 // The context must be created on the same thread as the network service.
51 context_.reset(new NetworkContext(GetBasePath()));
52 }
53
54 bool NetworkServiceLoader::ConfigureIncomingConnection(
39 ApplicationConnection* connection) { 55 ApplicationConnection* connection) {
40 connection->AddService<ProfileServiceImpl>(); 56 connection->AddService<NetworkServiceImpl>(context_.get());
41 return true; 57 return true;
42 } 58 }
43 59
44 } // namespace shell 60 } // namespace shell
45 } // namespace mojo 61 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/network_service_loader.h ('k') | mojo/shell/profile_service_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698