Commit 2d6f7dde authored by qsr@chromium.org's avatar qsr@chromium.org

Bundle the network service in the shell on Android.

Also, remove the profile service that was only used by the network
service because it couldn't access the path service on android.

R=darin@chromium.org

Review URL: https://codereview.chromium.org/395163002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283730 0039d316-1c4b-4281-b951-d872f2087c98
parent a1ce0830
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
'mojo_network_service', 'mojo_network_service',
'mojo_pepper_container_app', 'mojo_pepper_container_app',
'mojo_png_viewer', 'mojo_png_viewer',
'mojo_profile_service',
'mojo_public_application_unittests', 'mojo_public_application_unittests',
'mojo_public_test_utils', 'mojo_public_test_utils',
'mojo_public_bindings_unittests', 'mojo_public_bindings_unittests',
...@@ -545,7 +544,6 @@ ...@@ -545,7 +544,6 @@
'mojo_gles2_impl', 'mojo_gles2_impl',
'mojo_native_viewport_service', 'mojo_native_viewport_service',
'mojo_network_bindings', 'mojo_network_bindings',
'mojo_profile_service',
'mojo_service_manager', 'mojo_service_manager',
'mojo_service_provider_bindings', 'mojo_service_provider_bindings',
'mojo_spy', 'mojo_spy',
...@@ -579,8 +577,6 @@ ...@@ -579,8 +577,6 @@
'shell/mojo_url_resolver.h', 'shell/mojo_url_resolver.h',
'shell/out_of_process_dynamic_service_runner.cc', 'shell/out_of_process_dynamic_service_runner.cc',
'shell/out_of_process_dynamic_service_runner.h', 'shell/out_of_process_dynamic_service_runner.h',
'shell/profile_service_loader.cc',
'shell/profile_service_loader.h',
'shell/run.cc', 'shell/run.cc',
'shell/run.h', 'shell/run.h',
'shell/switches.cc', 'shell/switches.cc',
...@@ -599,6 +595,15 @@ ...@@ -599,6 +595,15 @@
'../dbus/dbus.gyp:dbus', '../dbus/dbus.gyp:dbus',
], ],
}], }],
['OS=="android"', {
'dependencies': [
'mojo_network_service_lib',
],
'sources': [
'shell/network_service_loader.cc',
'shell/network_service_loader.h',
],
}],
['use_aura==1', { ['use_aura==1', {
'dependencies': [ 'dependencies': [
# These are only necessary as long as we hard code use of ViewManager. # These are only necessary as long as we hard code use of ViewManager.
...@@ -927,9 +932,6 @@ ...@@ -927,9 +932,6 @@
'java_in_dir': '<(DEPTH)/mojo/shell/android/apk', 'java_in_dir': '<(DEPTH)/mojo/shell/android/apk',
'resource_dir': '<(DEPTH)/mojo/shell/android/apk/res', 'resource_dir': '<(DEPTH)/mojo/shell/android/apk/res',
'native_lib_target': 'libmojo_shell', 'native_lib_target': 'libmojo_shell',
'additional_bundled_libs': [
'<(PRODUCT_DIR)/libmojo_network_service.so',
],
}, },
'includes': [ '../build/java_apk.gypi' ], 'includes': [ '../build/java_apk.gypi' ],
} }
......
...@@ -361,8 +361,8 @@ ...@@ -361,8 +361,8 @@
], ],
}, },
{ {
'target_name': 'mojo_network_service', 'target_name': 'mojo_network_service_lib',
'type': 'loadable_module', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'../base/base.gyp:base', '../base/base.gyp:base',
'../net/net.gyp:net', '../net/net.gyp:net',
...@@ -371,14 +371,11 @@ ...@@ -371,14 +371,11 @@
'mojo_common_lib', 'mojo_common_lib',
'mojo_environment_chromium', 'mojo_environment_chromium',
'mojo_network_bindings', 'mojo_network_bindings',
'mojo_profile_service_bindings',
'<(mojo_system_for_loadable_module)',
], ],
'export_dependent_settings': [ 'export_dependent_settings': [
'mojo_network_bindings', 'mojo_network_bindings',
], ],
'sources': [ 'sources': [
'services/network/main.cc',
'services/network/network_context.cc', 'services/network/network_context.cc',
'services/network/network_context.h', 'services/network/network_context.h',
'services/network/network_service_impl.cc', 'services/network/network_service_impl.cc',
...@@ -387,6 +384,21 @@ ...@@ -387,6 +384,21 @@
'services/network/url_loader_impl.h', 'services/network/url_loader_impl.h',
], ],
}, },
{
'target_name': 'mojo_network_service',
'type': 'loadable_module',
'dependencies': [
'mojo_network_bindings',
'mojo_network_service_lib',
'<(mojo_system_for_loadable_module)',
],
'export_dependent_settings': [
'mojo_network_bindings',
],
'sources': [
'services/network/main.cc',
],
},
{ {
'target_name': 'mojo_surfaces_service', 'target_name': 'mojo_surfaces_service',
'type': 'shared_library', 'type': 'shared_library',
...@@ -621,32 +633,6 @@ ...@@ -621,32 +633,6 @@
'services/test_service/test_request_tracker_impl.h', 'services/test_service/test_request_tracker_impl.h',
], ],
}, },
{
'target_name': 'mojo_profile_service_bindings',
'type': 'static_library',
'sources': [
'services/public/interfaces/profile/profile_service.mojom',
],
'includes': [ 'public/tools/bindings/mojom_bindings_generator.gypi' ],
'export_dependent_settings': [
'mojo_cpp_bindings',
],
'dependencies': [
'mojo_cpp_bindings',
],
},
{
'target_name': 'mojo_profile_service',
'type': 'static_library',
'sources': [
'services/profile/profile_service_impl.cc',
'services/profile/profile_service_impl.h',
],
'dependencies': [
'../base/base.gyp:base',
'mojo_profile_service_bindings',
],
},
], ],
'conditions': [ 'conditions': [
['use_aura==1', { ['use_aura==1', {
......
...@@ -3,47 +3,24 @@ ...@@ -3,47 +3,24 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/bind.h" #include "base/base_paths.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "mojo/public/cpp/application/application_connection.h" #include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
#include "mojo/services/network/network_context.h" #include "mojo/services/network/network_context.h"
#include "mojo/services/network/network_service_impl.h" #include "mojo/services/network/network_service_impl.h"
#include "mojo/services/public/interfaces/profile/profile_service.mojom.h"
namespace {
void OnPathReceived(base::FilePath* path, const mojo::String& path_as_string) {
DCHECK(!path_as_string.is_null());
#if defined(OS_POSIX)
*path = base::FilePath(path_as_string);
#elif defined(OS_WIN)
*path = base::FilePath::FromUTF8Unsafe(path_as_string);
#else
#error Not implemented
#endif
}
} // namespace
class Delegate : public mojo::ApplicationDelegate { class Delegate : public mojo::ApplicationDelegate {
public: public:
Delegate() {} Delegate() {}
virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE { virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
mojo::InterfacePtr<mojo::ProfileService> profile_service;
app->ConnectToService("mojo:profile_service", &profile_service);
base::FilePath base_path; base::FilePath base_path;
profile_service->GetPath( CHECK(PathService::Get(base::DIR_TEMP, &base_path));
mojo::ProfileService::PATH_KEY_DIR_TEMP,
base::Bind(&OnPathReceived, base::Unretained(&base_path)));
profile_service.WaitForIncomingMethodCall();
DCHECK(!base_path.value().empty());
base_path = base_path.Append(FILE_PATH_LITERAL("network_service")); base_path = base_path.Append(FILE_PATH_LITERAL("network_service"));
context_.reset(new mojo::NetworkContext(base_path)); context_.reset(new mojo::NetworkContext(base_path));
} }
......
include_rules = [
"+mojo/services/public/interfaces/profile"
]
// Copyright 2014 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 "mojo/services/profile/profile_service_impl.h"
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
namespace {
int BaseKeyForMojoKey(mojo::ProfileService::PathKey key) {
switch(key) {
case mojo::ProfileService::PATH_KEY_DIR_TEMP:
return base::DIR_TEMP;
default:
return base::PATH_START;
}
}
} // namespace
namespace mojo {
ProfileServiceImpl::ProfileServiceImpl(ApplicationConnection* connection) {
}
ProfileServiceImpl::~ProfileServiceImpl() {
}
void ProfileServiceImpl::GetPath(
PathKey key,
const mojo::Callback<void(mojo::String)>& callback) {
int base_key = BaseKeyForMojoKey(key);
if (base_key == base::PATH_START) {
callback.Run(mojo::String());
return;
}
base::FilePath path;
if (!PathService::Get(base_key, &path)) {
callback.Run(mojo::String());
return;
}
#if defined(OS_POSIX)
callback.Run(path.value());
#elif defined(OS_WIN)
callback.Run(path.AsUTF8Unsafe());
#else
#error Not implemented
#endif
}
} // namespace mojo
// Copyright 2014 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.
#ifndef MOJO_SERVICES_PROFILE_PROFILE_SERVICE_IMPL_H_
#define MOJO_SERVICES_PROFILE_PROFILE_SERVICE_IMPL_H_
#include "base/compiler_specific.h"
#include "mojo/public/cpp/system/macros.h"
#include "mojo/services/public/interfaces/profile/profile_service.mojom.h"
namespace mojo {
class ApplicationConnection;
class ProfileServiceImpl : public InterfaceImpl<ProfileService> {
public:
ProfileServiceImpl(ApplicationConnection* connection);
virtual ~ProfileServiceImpl();
// |ProfileService| methods:
virtual void GetPath(
PathKey key,
const mojo::Callback<void(mojo::String)>& callback)
OVERRIDE;
private:
MOJO_DISALLOW_COPY_AND_ASSIGN(ProfileServiceImpl);
};
} // namespace mojo
#endif // MOJO_SERVICES_PROFILE_PROFILE_SERVICE_IMPL_H_
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "mojo/shell/dynamic_service_loader.h" #include "mojo/shell/dynamic_service_loader.h"
#include "mojo/shell/in_process_dynamic_service_runner.h" #include "mojo/shell/in_process_dynamic_service_runner.h"
#include "mojo/shell/out_of_process_dynamic_service_runner.h" #include "mojo/shell/out_of_process_dynamic_service_runner.h"
#include "mojo/shell/profile_service_loader.h"
#include "mojo/shell/switches.h" #include "mojo/shell/switches.h"
#include "mojo/spy/spy.h" #include "mojo/spy/spy.h"
...@@ -26,6 +25,10 @@ ...@@ -26,6 +25,10 @@
#include "mojo/shell/dbus_service_loader_linux.h" #include "mojo/shell/dbus_service_loader_linux.h"
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)
#if defined(OS_ANDROID)
#include "mojo/shell/network_service_loader.h"
#endif // defined(OS_ANDROID)
#if defined(USE_AURA) #if defined(USE_AURA)
#include "mojo/shell/view_manager_loader.h" #include "mojo/shell/view_manager_loader.h"
#endif #endif
...@@ -120,14 +123,22 @@ Context::Context() ...@@ -120,14 +123,22 @@ Context::Context()
"dbus"); "dbus");
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)
service_manager_.SetLoaderForURL(
scoped_ptr<ServiceLoader>(new ProfileServiceLoader()),
GURL("mojo:profile_service"));
if (cmdline->HasSwitch(switches::kSpy)) { if (cmdline->HasSwitch(switches::kSpy)) {
spy_.reset(new mojo::Spy(&service_manager_, spy_.reset(new mojo::Spy(&service_manager_,
cmdline->GetSwitchValueASCII(switches::kSpy))); cmdline->GetSwitchValueASCII(switches::kSpy)));
} }
#if defined(OS_ANDROID)
// On android, the network service is bundled with the shell because the
// network stack depends on the android runtime.
service_manager_.SetLoaderForURL(
scoped_ptr<ServiceLoader>(
new BackgroundServiceLoader(
scoped_ptr<ServiceLoader>(new NetworkServiceLoader()),
"network_service",
base::MessageLoop::TYPE_IO)),
GURL("mojo:mojo_network_service"));
#endif
} }
Context::~Context() { Context::~Context() {
......
...@@ -2,23 +2,34 @@ ...@@ -2,23 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "mojo/shell/profile_service_loader.h" #include "mojo/shell/network_service_loader.h"
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "mojo/public/cpp/application/application_connection.h" #include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/application/application_impl.h"
#include "mojo/services/profile/profile_service_impl.h" #include "mojo/services/network/network_service_impl.h"
namespace {
base::FilePath GetBasePath() {
base::FilePath path;
CHECK(PathService::Get(base::DIR_TEMP, &path));
return path.Append(FILE_PATH_LITERAL("network_service"));
}
}
namespace mojo { namespace mojo {
namespace shell { namespace shell {
ProfileServiceLoader::ProfileServiceLoader() { NetworkServiceLoader::NetworkServiceLoader() {
} }
ProfileServiceLoader::~ProfileServiceLoader() { NetworkServiceLoader::~NetworkServiceLoader() {
} }
void ProfileServiceLoader::LoadService( void NetworkServiceLoader::LoadService(
ServiceManager* manager, ServiceManager* manager,
const GURL& url, const GURL& url,
ScopedMessagePipeHandle shell_handle) { ScopedMessagePipeHandle shell_handle) {
...@@ -30,14 +41,19 @@ void ProfileServiceLoader::LoadService( ...@@ -30,14 +41,19 @@ void ProfileServiceLoader::LoadService(
} }
} }
void ProfileServiceLoader::OnServiceError(ServiceManager* manager, void NetworkServiceLoader::OnServiceError(ServiceManager* manager,
const GURL& url) { const GURL& url) {
apps_.erase(reinterpret_cast<uintptr_t>(manager)); apps_.erase(reinterpret_cast<uintptr_t>(manager));
} }
bool ProfileServiceLoader::ConfigureIncomingConnection( void NetworkServiceLoader::Initialize(ApplicationImpl* app) {
// The context must be created on the same thread as the network service.
context_.reset(new NetworkContext(GetBasePath()));
}
bool NetworkServiceLoader::ConfigureIncomingConnection(
ApplicationConnection* connection) { ApplicationConnection* connection) {
connection->AddService<ProfileServiceImpl>(); connection->AddService<NetworkServiceImpl>(context_.get());
return true; return true;
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef MOJO_SHELL_PROFILE_SERVICE_LOADER_H_ #ifndef MOJO_SHELL_NETWORK_SERVICE_LOADER_H_
#define MOJO_SHELL_PROFILE_SERVICE_LOADER_H_ #define MOJO_SHELL_NETWORK_SERVICE_LOADER_H_
#include <map> #include <map>
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/service_manager/service_loader.h" #include "mojo/service_manager/service_loader.h"
#include "mojo/services/network/network_context.h"
namespace mojo { namespace mojo {
...@@ -18,11 +19,11 @@ class ApplicationImpl; ...@@ -18,11 +19,11 @@ class ApplicationImpl;
namespace shell { namespace shell {
// ServiceLoader responsible for creating connections to the ProfileService. // ServiceLoader responsible for creating connections to the NetworkService.
class ProfileServiceLoader : public ServiceLoader, public ApplicationDelegate { class NetworkServiceLoader : public ServiceLoader, public ApplicationDelegate {
public: public:
ProfileServiceLoader(); NetworkServiceLoader();
virtual ~ProfileServiceLoader(); virtual ~NetworkServiceLoader();
private: private:
// ServiceLoader overrides: // ServiceLoader overrides:
...@@ -34,15 +35,17 @@ class ProfileServiceLoader : public ServiceLoader, public ApplicationDelegate { ...@@ -34,15 +35,17 @@ class ProfileServiceLoader : public ServiceLoader, public ApplicationDelegate {
const GURL& url) OVERRIDE; const GURL& url) OVERRIDE;
// ApplicationDelegate overrides. // ApplicationDelegate overrides.
virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE;
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
MOJO_OVERRIDE; MOJO_OVERRIDE;
base::ScopedPtrHashMap<uintptr_t, ApplicationImpl> apps_; base::ScopedPtrHashMap<uintptr_t, ApplicationImpl> apps_;
scoped_ptr<NetworkContext> context_;
DISALLOW_COPY_AND_ASSIGN(ProfileServiceLoader); DISALLOW_COPY_AND_ASSIGN(NetworkServiceLoader);
}; };
} // namespace shell } // namespace shell
} // namespace mojo } // namespace mojo
#endif // MOJO_SHELL_PROFILE_SERVICE_LOADER_H_ #endif // MOJO_SHELL_NETWORK_SERVICE_LOADER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment