Skip to content

Commit

Permalink
Convert ConnectToApplication to take a params class
Browse files Browse the repository at this point in the history
R=sky@chromium.org
BUG=none

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

Cr-Commit-Position: refs/heads/master@{#360954}
  • Loading branch information
ben authored and Commit bot committed Nov 20, 2015
1 parent be36e8f commit a5404b5
Show file tree
Hide file tree
Showing 49 changed files with 116 additions and 181 deletions.
4 changes: 1 addition & 3 deletions components/clipboard/clipboard_apptest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ class ClipboardAppTest : public mojo::test::ApplicationTestBase {

void SetUp() override {
mojo::test::ApplicationTestBase::SetUp();
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:clipboard");
application_impl()->ConnectToService(request.Pass(), &clipboard_);
application_impl()->ConnectToService("mojo:clipboard", &clipboard_);
}

uint64_t GetSequenceNumber() {
Expand Down
5 changes: 2 additions & 3 deletions components/devtools_service/devtools_http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,8 @@ DevToolsHttpServer::DevToolsHttpServer(DevToolsService* service,
VLOG(1) << "Remote debugging HTTP server is started on port "
<< remote_debugging_port << ".";
mojo::NetworkServicePtr network_service;
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = "mojo:network_service";
service_->application()->ConnectToService(request.Pass(), &network_service);
service_->application()->ConnectToService("mojo:network_service",
&network_service);

mojo::NetAddressPtr local_address(mojo::NetAddress::New());
local_address->family = mojo::NET_ADDRESS_FAMILY_IPV4;
Expand Down
5 changes: 1 addition & 4 deletions components/filesystem/files_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ FilesTestBase::~FilesTestBase() {

void FilesTestBase::SetUp() {
ApplicationTestBase::SetUp();

mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:filesystem");
application_impl()->ConnectToService(request.Pass(), &files_);
application_impl()->ConnectToService("mojo:filesystem", &files_);
}

void FilesTestBase::OnFileSystemShutdown() {
Expand Down
4 changes: 1 addition & 3 deletions components/font_service/public/cpp/font_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ FontLoader::FontLoader(mojo::Shell* shell) {
}

FontLoader::FontLoader(mojo::ApplicationImpl* application_impl) {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:font_service");
FontServicePtr font_service;
application_impl->ConnectToService(request.Pass(), &font_service);
application_impl->ConnectToService("mojo:font_service", &font_service);

thread_ = new internal::FontServiceThread(font_service.Pass());
}
Expand Down
1 change: 1 addition & 0 deletions components/html_viewer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ mojo_native_application("apptests") {
"//components/web_view/public/interfaces",
"//mojo/application/public/cpp:sources",
"//mojo/application/public/cpp:test_support",
"//mojo/converters/network",
"//mojo/public/c/system:for_shared_library",
"//net:test_support",
"//testing/gtest",
Expand Down
1 change: 1 addition & 0 deletions components/html_viewer/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ include_rules = [
"+mojo/common",
"+mojo/converters/geometry",
"+mojo/converters/input_events",
"+mojo/converters/network",
"+mojo/converters/surfaces",
"+mojo/gles2",
"+mojo/gpu",
Expand Down
8 changes: 3 additions & 5 deletions components/html_viewer/ax_provider_apptest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "components/web_view/public/interfaces/frame.mojom.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/application/public/cpp/application_test_base.h"
#include "mojo/converters/network/network_type_converters.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/mojo_services/src/accessibility/public/interfaces/accessibility.mojom.h"
Expand Down Expand Up @@ -77,12 +78,9 @@ TEST_F(AXProviderTest, HelloWorld) {
ASSERT_TRUE(server.Start());

// Connect to the URL through the mojo:html_viewer content handler.
const uint16_t assigned_port = server.host_port_pair().port();
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From(
base::StringPrintf("http://127.0.0.1:%u/test.html", assigned_port));
scoped_ptr<ApplicationConnection> connection =
application_impl()->ConnectToApplication(request.Pass());
application_impl()->ConnectToApplication(
server.GetURL("/test.html").spec());

// Embed the html_viewer in a Window.
mus::mojom::WindowTreeClientPtr tree_client;
Expand Down
8 changes: 2 additions & 6 deletions components/html_viewer/blink_platform_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ BlinkPlatformImpl::BlinkPlatformImpl(
main_thread_task_runner_(renderer_scheduler->DefaultTaskRunner()),
main_thread_(renderer_scheduler->CreateMainThread()) {
if (app) {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:network_service");
scoped_ptr<mojo::ApplicationConnection> connection =
app->ConnectToApplication(request.Pass());
app->ConnectToApplication("mojo:network_service");
connection->ConnectToService(&web_socket_factory_);
connection->ConnectToService(&url_loader_factory_);

Expand All @@ -88,9 +86,7 @@ BlinkPlatformImpl::BlinkPlatformImpl(
cookie_jar_.reset(new WebCookieJarImpl(cookie_store.Pass()));

mojo::ClipboardPtr clipboard;
mojo::URLRequestPtr request2(mojo::URLRequest::New());
request2->url = mojo::String::From("mojo:clipboard");
app->ConnectToService(request2.Pass(), &clipboard);
app->ConnectToService("mojo:clipboard", &clipboard);
clipboard_.reset(new WebClipboardImpl(clipboard.Pass()));
}
}
Expand Down
4 changes: 1 addition & 3 deletions components/html_viewer/global_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ void GlobalState::InitIfNecessary(const gfx::Size& screen_size_in_pixels,
DisplaysFromSizeAndScale(screen_size_in_pixels_, device_pixel_ratio_)));
base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);

mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:mus");
app_->ConnectToService(request.Pass(), &gpu_service_);
app_->ConnectToService("mojo:mus", &gpu_service_);
gpu_service_->GetGpuInfo(base::Bind(&GlobalState::GetGpuInfoCallback,
base::Unretained(this)));

Expand Down
6 changes: 1 addition & 5 deletions components/html_viewer/html_document_application_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ void HTMLDocumentApplicationDelegate::OnTerminate() {

// ApplicationDelegate;
void HTMLDocumentApplicationDelegate::Initialize(mojo::ApplicationImpl* app) {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:network_service");
scoped_ptr<mojo::ApplicationConnection> connection =
app_.ConnectToApplication(request.Pass());
connection->ConnectToService(&url_loader_factory_);
app_.ConnectToService("mojo:network_service", &url_loader_factory_);
}

bool HTMLDocumentApplicationDelegate::ConfigureIncomingConnection(
Expand Down
4 changes: 1 addition & 3 deletions components/html_viewer/html_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ void InitializeWebLayerTreeView(WebLayerTreeViewImpl* web_layer_tree_view,
mus::Window* window,
blink::WebWidget* widget) {
DCHECK(window);
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:mus");
mus::mojom::GpuPtr gpu_service;
app->ConnectToService(request.Pass(), &gpu_service);
app->ConnectToService("mojo:mus", &gpu_service);
web_layer_tree_view->Initialize(gpu_service.Pass(), window, widget);
}

Expand Down
4 changes: 1 addition & 3 deletions components/html_viewer/layout_test_html_viewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ void LayoutTestHTMLViewer::TestFinished() {
test_interfaces_->ResetAll();

web_view::LayoutTestRunnerPtr test_runner_ptr;
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:web_view_test_runner");
app()->ConnectToService(request.Pass(), &test_runner_ptr);
app()->ConnectToService("mojo:web_view_test_runner", &test_runner_ptr);
test_runner_ptr->TestFinished();
}

Expand Down
8 changes: 2 additions & 6 deletions components/html_viewer/stats_collection_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ tracing::StartupPerformanceDataCollectorPtr StatsCollectionController::Install(

v8::Context::Scope context_scope(context);

mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:tracing");
scoped_ptr<mojo::ApplicationConnection> connection =
app->ConnectToApplication(request.Pass());
app->ConnectToApplication("mojo:tracing");
if (!connection)
return nullptr;
tracing::StartupPerformanceDataCollectorPtr collector_for_controller;
Expand All @@ -109,10 +107,8 @@ StatsCollectionController::ConnectToDataCollector(mojo::ApplicationImpl* app) {
return nullptr;
}

mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:tracing");
tracing::StartupPerformanceDataCollectorPtr collector;
app->ConnectToService(request.Pass(), &collector);
app->ConnectToService("mojo:tracing", &collector);
return collector.Pass();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
gl_info->rendererInfo = gpu_info->renderer_info.To<blink::WebString>();
gl_info->driverVersion = gpu_info->driver_version.To<blink::WebString>();

mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:mus");
mus::mojom::GpuPtr gpu_service;
app->ConnectToService(request.Pass(), &gpu_service);
app->ConnectToService("mojo:mus", &gpu_service);
mus::mojom::CommandBufferPtr cb;
gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb));
return new WebGraphicsContext3DCommandBufferImpl(
Expand Down
4 changes: 1 addition & 3 deletions components/mus/public/cpp/lib/window_tree_host_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ void CreateSingleWindowTreeHost(
mojom::WindowManagerPtr window_manager,
WindowManagerDelegate* window_manager_delegate) {
mojom::WindowTreeHostFactoryPtr factory;
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = "mojo:mus";
app->ConnectToService(request.Pass(), &factory);
app->ConnectToService("mojo:mus", &factory);
CreateWindowTreeHost(factory.get(), mojom::WindowTreeHostClientPtr(),
delegate, host, window_manager.Pass(),
window_manager_delegate);
Expand Down
6 changes: 1 addition & 5 deletions components/mus/ws/window_manager_client_apptest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,8 @@ class WindowServerTest : public WindowServerTestBase {
// WindowTreeClient.
mus::mojom::WindowTreeClientPtr
ConnectToApplicationAndGetWindowServerClient() {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From(application_impl()->url());
scoped_ptr<mojo::ApplicationConnection> connection =
application_impl()->ConnectToApplication(request.Pass());
mus::mojom::WindowTreeClientPtr client;
connection->ConnectToService(&client);
application_impl()->ConnectToService(application_impl()->url(), &client);
return client.Pass();
}

Expand Down
10 changes: 2 additions & 8 deletions components/mus/ws/window_tree_apptest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,8 @@ bool EmbedUrl(mojo::ApplicationImpl* app,
bool result = false;
base::RunLoop run_loop;
{
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From(url);
scoped_ptr<ApplicationConnection> connection =
app->ConnectToApplication(request.Pass());
mojom::WindowTreeClientPtr client;
connection->ConnectToService(&client);
app->ConnectToService(url.get(), &client);
ws->Embed(root_id, client.Pass(), mojom::WindowTree::ACCESS_POLICY_DEFAULT,
base::Bind(&EmbedCallbackImpl, &run_loop, &result));
}
Expand Down Expand Up @@ -540,11 +536,9 @@ class WindowTreeAppTest : public mojo::test::ApplicationTestBase,
void SetUp() override {
ApplicationTestBase::SetUp();
client_factory_.reset(new WindowTreeClientFactory(application_impl()));
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:mus");

mojom::WindowTreeHostFactoryPtr factory;
application_impl()->ConnectToService(request.Pass(), &factory);
application_impl()->ConnectToService("mojo:mus", &factory);

mojom::WindowTreeClientPtr tree_client_ptr;
ws_client1_.reset(new TestWindowTreeClientImpl(application_impl()));
Expand Down
4 changes: 1 addition & 3 deletions components/resource_provider/public/cpp/resource_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ base::File GetFileFromHandle(mojo::ScopedHandle handle) {
ResourceLoader::ResourceLoader(mojo::ApplicationImpl* app,
const std::set<std::string>& paths)
: loaded_(false), did_block_(false) {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:resource_provider");
app->ConnectToService(request.Pass(), &resource_provider_);
app->ConnectToService("mojo:resource_provider", &resource_provider_);
std::vector<std::string> paths_vector(paths.begin(), paths.end());
resource_provider_->GetResources(
mojo::Array<mojo::String>::From(paths_vector),
Expand Down
5 changes: 3 additions & 2 deletions components/web_view/frame_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ void FrameConnection::Init(mojo::ApplicationImpl* app,
filter->filter.insert("mojo:font_service", font_service_interfaces.Pass());
#endif

application_connection_ = app->ConnectToApplicationWithCapabilityFilter(
request.Pass(), filter.Pass());
mojo::ApplicationImpl::ConnectParams params(request.Pass());
params.set_filter(filter.Pass());
application_connection_ = app->ConnectToApplication(&params);
application_connection_->ConnectToService(&frame_client_);
application_connection_->AddContentHandlerIDCallback(on_got_id_callback);
}
Expand Down
4 changes: 1 addition & 3 deletions components/web_view/frame_devtools_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ void FrameDevToolsAgent::RegisterAgentIfNecessary() {
if (binding_.is_bound())
return;

mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = "mojo:devtools_service";
DevToolsRegistryPtr devtools_registry;
app_->ConnectToService(request.Pass(), &devtools_registry);
app_->ConnectToService("mojo:devtools_service", &devtools_registry);

DevToolsAgentPtr agent;
binding_.Bind(&agent);
Expand Down
5 changes: 1 addition & 4 deletions components/web_view/public/cpp/web_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ WebView::WebView(mojom::WebViewClient* client) : binding_(client) {}
WebView::~WebView() {}

void WebView::Init(mojo::ApplicationImpl* app, mus::Window* window) {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = "mojo:web_view";

mojom::WebViewClientPtr client;
mojo::InterfaceRequest<mojom::WebViewClient> client_request =
GetProxy(&client);
binding_.Bind(client_request.Pass());

mojom::WebViewFactoryPtr factory;
app->ConnectToService(request.Pass(), &factory);
app->ConnectToService("mojo:web_view", &factory);
factory->CreateWebView(client.Pass(), GetProxy(&web_view_));

mus::mojom::WindowTreeClientPtr window_tree_client;
Expand Down
3 changes: 1 addition & 2 deletions content/browser/mojo/mojo_shell_client_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ void RegisterChildWithExternalShell(int child_process_id,
base::ThreadTaskRunnerHandle::Get()));
mojo::shell::mojom::ApplicationManagerPtr application_manager;
MojoShellConnection::Get()->GetApplication()->ConnectToService(
mojo::URLRequest::From(std::string("mojo:shell")),
&application_manager);
"mojo:shell", &application_manager);
// The content of the URL/qualifier we pass is actually meaningless, it's only
// important that they're unique per process.
// TODO(beng): We need to specify a restrictive CapabilityFilter here that
Expand Down
5 changes: 3 additions & 2 deletions content/browser/mojo/mojo_shell_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,9 @@ void MojoShellContext::ConnectToApplication(
mojo::ServiceProviderPtr exposed_services,
const mojo::shell::CapabilityFilter& filter,
const mojo::Shell::ConnectToApplicationCallback& callback) {
proxy_.Get()->ConnectToApplication(url, requestor_url, request.Pass(),
exposed_services.Pass(), filter, callback);
proxy_.Get()->ConnectToApplication(url, requestor_url,
request.Pass(), exposed_services.Pass(),
filter, callback);
}

void MojoShellContext::ConnectToApplicationOnOwnThread(
Expand Down
4 changes: 1 addition & 3 deletions device/devices_app/devices_apptest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class DevicesAppTest : public mojo::test::ApplicationTestBase {

void SetUp() override {
ApplicationTestBase::SetUp();
mojo::URLRequestPtr request = mojo::URLRequest::New();
request->url = "mojo:devices";
application_impl()->ConnectToService(request.Pass(), &usb_device_manager_);
application_impl()->ConnectToService("mojo:devices", &usb_device_manager_);
}

usb::DeviceManager* usb_device_manager() { return usb_device_manager_.get(); }
Expand Down
4 changes: 1 addition & 3 deletions mandoline/ui/desktop_ui/browser_apptest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class BrowserTest : public mojo::test::ApplicationTestBase {
// mojo::test::ApplicationTestBase:
void SetUp() override {
mojo::test::ApplicationTestBase::SetUp();
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:desktop_ui");
application_impl()->ConnectToService(request.Pass(), &launch_handler_);
application_impl()->ConnectToService("mojo:desktop_ui", &launch_handler_);
ASSERT_TRUE(launch_handler_.is_bound());
}

Expand Down
4 changes: 1 addition & 3 deletions mandoline/ui/desktop_ui/browser_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ void BrowserManager::Initialize(mojo::ApplicationImpl* app) {
app_ = app;
tracing_.Initialize(app);

mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = "mojo:mus";
app_->ConnectToService(request.Pass(), &host_factory_);
app_->ConnectToService("mojo:mus", &host_factory_);

base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
// Create a Browser for each valid URL in the command line.
Expand Down
8 changes: 2 additions & 6 deletions mandoline/ui/desktop_ui/browser_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ void BrowserWindow::Close() {
void BrowserWindow::ShowOmnibox() {
TRACE_EVENT0("desktop_ui", "BrowserWindow::ShowOmnibox");
if (!omnibox_.get()) {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:omnibox");
omnibox_connection_ = app_->ConnectToApplication(request.Pass());
omnibox_connection_ = app_->ConnectToApplication("mojo:omnibox");
omnibox_connection_->AddService<ViewEmbedder>(this);
omnibox_connection_->ConnectToService(&omnibox_);
omnibox_connection_->SetRemoteServiceProviderConnectionErrorHandler(
Expand Down Expand Up @@ -242,10 +240,8 @@ void BrowserWindow::OnEmbed(mus::Window* root) {
if (!recorded_browser_startup_metrics &&
base::CommandLine::ForCurrentProcess()->HasSwitch(
tracing::kEnableStatsCollectionBindings)) {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:tracing");
tracing::StartupPerformanceDataCollectorPtr collector;
app_->ConnectToService(request.Pass(), &collector);
app_->ConnectToService("mojo:tracing", &collector);
collector->SetBrowserWindowDisplayTicks(display_ticks.ToInternalValue());
collector->SetBrowserOpenTabsTimeDelta(open_tabs_delta.ToInternalValue());
collector->SetBrowserMessageLoopStartTicks(
Expand Down
4 changes: 1 addition & 3 deletions mash/wm/window_manager_apptest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class WindowManagerAppTest : public mojo::test::ApplicationTestBase,

protected:
void ConnectToWindowManager(mus::mojom::WindowManagerPtr* window_manager) {
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = "mojo:example_wm";
application_impl()->ConnectToService(request.Pass(), window_manager);
application_impl()->ConnectToService("mojo:example_wm", window_manager);
}

mus::Window* OpenWindow(mus::mojom::WindowManager* window_manager) {
Expand Down
4 changes: 1 addition & 3 deletions media/mojo/services/media_apptest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ class MediaAppTest : public mojo::test::ApplicationTestBase {
void SetUp() override {
ApplicationTestBase::SetUp();

mojo::URLRequestPtr request = mojo::URLRequest::New();
request->url = "mojo:media";
connection_ = application_impl()->ConnectToApplication(request.Pass());
connection_ = application_impl()->ConnectToApplication("mojo:media");
connection_->SetRemoteServiceProviderConnectionErrorHandler(
base::Bind(&MediaAppTest::ConnectionClosed, base::Unretained(this)));

Expand Down
Loading

0 comments on commit a5404b5

Please sign in to comment.