Skip to content

Commit

Permalink
Convert Pass()→std::move() in //mojo
Browse files Browse the repository at this point in the history
BUG=557422
R=avi@chromium.org
TBR=ben@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#366168}
  • Loading branch information
zetafunction authored and Commit bot committed Dec 18, 2015
1 parent 2a370ee commit 6196e1f
Show file tree
Hide file tree
Showing 65 changed files with 440 additions and 331 deletions.
5 changes: 3 additions & 2 deletions mojo/application/public/cpp/application_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_

#include <string>
#include <utility>

#include "base/memory/weak_ptr.h"
#include "mojo/application/public/cpp/lib/interface_factory_connector.h"
Expand Down Expand Up @@ -82,8 +83,8 @@ class ApplicationConnection {
void ConnectToService(InterfacePtr<Interface>* ptr) {
if (ServiceProvider* sp = GetServiceProvider()) {
MessagePipe pipe;
ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u));
sp->ConnectToService(Interface::Name_, pipe.handle1.Pass());
ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u));
sp->ConnectToService(Interface::Name_, std::move(pipe.handle1));
}
}

Expand Down
9 changes: 4 additions & 5 deletions mojo/application/public/cpp/application_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_
#define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_

#include <utility>
#include <vector>

#include "base/macros.h"
Expand Down Expand Up @@ -66,11 +67,9 @@ class ApplicationImpl : public Application {
explicit ConnectParams(URLRequestPtr request);
~ConnectParams();

URLRequestPtr TakeRequest() { return request_.Pass(); }
CapabilityFilterPtr TakeFilter() { return filter_.Pass(); }
void set_filter(CapabilityFilterPtr filter) {
filter_ = filter.Pass();
}
URLRequestPtr TakeRequest() { return std::move(request_); }
CapabilityFilterPtr TakeFilter() { return std::move(filter_); }
void set_filter(CapabilityFilterPtr filter) { filter_ = std::move(filter); }

private:
URLRequestPtr request_;
Expand Down
6 changes: 4 additions & 2 deletions mojo/application/public/cpp/connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef MOJO_APPLICATION_PUBLIC_CPP_CONNECT_H_
#define MOJO_APPLICATION_PUBLIC_CPP_CONNECT_H_

#include <utility>

#include "mojo/application/public/interfaces/service_provider.mojom.h"

namespace mojo {
Expand All @@ -14,8 +16,8 @@ template <typename Interface>
inline void ConnectToService(ServiceProvider* service_provider,
InterfacePtr<Interface>* ptr) {
MessagePipe pipe;
ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u));
service_provider->ConnectToService(Interface::Name_, pipe.handle1.Pass());
ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u));
service_provider->ConnectToService(Interface::Name_, std::move(pipe.handle1));
}

} // namespace mojo
Expand Down
36 changes: 18 additions & 18 deletions mojo/application/public/cpp/lib/application_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/application/public/cpp/application_impl.h"

#include <algorithm>
#include <utility>

#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "mojo/application/public/cpp/application_delegate.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/application/public/cpp/lib/service_registry.h"
#include "mojo/converters/network/network_type_converters.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
Expand All @@ -29,22 +29,22 @@ void DefaultTerminationClosure() {
ApplicationImpl::ConnectParams::ConnectParams(const std::string& url)
: ConnectParams(URLRequest::From(url)) {}
ApplicationImpl::ConnectParams::ConnectParams(URLRequestPtr request)
: request_(request.Pass()), filter_(CapabilityFilter::New()) {
: request_(std::move(request)), filter_(CapabilityFilter::New()) {
filter_->filter.mark_non_null();
}
ApplicationImpl::ConnectParams::~ConnectParams() {}

ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
InterfaceRequest<Application> request)
: ApplicationImpl(delegate, request.Pass(),
base::Bind(&DefaultTerminationClosure)) {
}
: ApplicationImpl(delegate,
std::move(request),
base::Bind(&DefaultTerminationClosure)) {}

ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
InterfaceRequest<Application> request,
const Closure& termination_closure)
: delegate_(delegate),
binding_(this, request.Pass()),
binding_(this, std::move(request)),
termination_closure_(termination_closure),
app_lifetime_helper_(this),
quit_requested_(false),
Expand Down Expand Up @@ -80,15 +80,15 @@ scoped_ptr<ApplicationConnection>
InterfaceRequest<ServiceProvider> remote_services_proxy =
GetProxy(&remote_services);
scoped_ptr<internal::ServiceRegistry> registry(new internal::ServiceRegistry(
application_url, application_url, remote_services.Pass(),
local_request.Pass(), allowed));
shell_->ConnectToApplication(request.Pass(), remote_services_proxy.Pass(),
local_services.Pass(),
params->TakeFilter().Pass(),
application_url, application_url, std::move(remote_services),
std::move(local_request), allowed));
shell_->ConnectToApplication(std::move(request),
std::move(remote_services_proxy),
std::move(local_services), params->TakeFilter(),
registry->GetConnectToApplicationCallback());
if (!delegate_->ConfigureOutgoingConnection(registry.get()))
return nullptr;
return registry.Pass();
return std::move(registry);
}

void ApplicationImpl::WaitForInitialize() {
Expand All @@ -108,7 +108,7 @@ void ApplicationImpl::Quit() {
}

void ApplicationImpl::Initialize(ShellPtr shell, const mojo::String& url) {
shell_ = shell.Pass();
shell_ = std::move(shell);
shell_.set_connection_error_handler([this]() { OnConnectionError(); });
url_ = url;
delegate_->Initialize(this);
Expand All @@ -121,7 +121,7 @@ void ApplicationImpl::AcceptConnection(
Array<String> allowed_interfaces,
const String& url) {
scoped_ptr<ApplicationConnection> registry(new internal::ServiceRegistry(
url, requestor_url, exposed_services.Pass(), services.Pass(),
url, requestor_url, std::move(exposed_services), std::move(services),
allowed_interfaces.To<std::set<std::string>>()));
if (!delegate_->ConfigureIncomingConnection(registry.get()))
return;
Expand All @@ -131,7 +131,7 @@ void ApplicationImpl::AcceptConnection(
if (quit_requested_)
quit_requested_ = false;

incoming_connections_.push_back(registry.Pass());
incoming_connections_.push_back(std::move(registry));
}

void ApplicationImpl::OnQuitRequested(const Callback<void(bool)>& callback) {
Expand Down Expand Up @@ -174,8 +174,8 @@ CapabilityFilterPtr CreatePermissiveCapabilityFilter() {
CapabilityFilterPtr filter(CapabilityFilter::New());
Array<String> all_interfaces;
all_interfaces.push_back("*");
filter->filter.insert("*", all_interfaces.Pass());
return filter.Pass();
filter->filter.insert("*", std::move(all_interfaces));
return filter;
}

} // namespace mojo
11 changes: 6 additions & 5 deletions mojo/application/public/cpp/lib/application_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/application/public/cpp/application_test_base.h"
#include <utility>

#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/application/public/cpp/application_test_base.h"
#include "mojo/application/public/interfaces/application.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/environment/environment.h"
Expand All @@ -31,7 +32,7 @@ ShellPtr g_shell;
class ShellGrabber : public Application {
public:
explicit ShellGrabber(InterfaceRequest<Application> application_request)
: binding_(this, application_request.Pass()) {}
: binding_(this, std::move(application_request)) {}

void WaitForInitialize() {
// Initialize is always the first call made on Application.
Expand All @@ -43,7 +44,7 @@ class ShellGrabber : public Application {
void Initialize(ShellPtr shell, const mojo::String& url) override {
g_url = url;
g_application_request = binding_.Unbind();
g_shell = shell.Pass();
g_shell = std::move(shell);
}

void AcceptConnection(const String& requestor_url,
Expand Down Expand Up @@ -127,11 +128,11 @@ void ApplicationTestBase::SetUp() {

// New applications are constructed for each test to avoid persisting state.
application_impl_ = new ApplicationImpl(GetApplicationDelegate(),
g_application_request.Pass());
std::move(g_application_request));

// Fake application initialization.
Application* application = application_impl_;
application->Initialize(g_shell.Pass(), g_url);
application->Initialize(std::move(g_shell), g_url);
}

void ApplicationTestBase::TearDown() {
Expand Down
32 changes: 16 additions & 16 deletions mojo/application/public/cpp/lib/content_handler_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/application/public/cpp/content_handler_factory.h"

#include <set>
#include <utility>

#include "base/bind.h"
#include "base/callback.h"
Expand All @@ -16,6 +15,7 @@
#include "mojo/application/public/cpp/application_delegate.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/application/public/cpp/application_runner.h"
#include "mojo/application/public/cpp/content_handler_factory.h"
#include "mojo/application/public/cpp/interface_factory_impl.h"
#include "mojo/message_pump/message_pump_mojo.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
Expand All @@ -36,8 +36,8 @@ class ApplicationThread : public base::PlatformThread::Delegate {
: handler_thread_(handler_thread),
termination_callback_(termination_callback),
handler_delegate_(handler_delegate),
application_request_(application_request.Pass()),
response_(response.Pass()),
application_request_(std::move(application_request)),
response_(std::move(response)),
destruct_callback_(destruct_callback) {}

~ApplicationThread() override {
Expand All @@ -46,8 +46,8 @@ class ApplicationThread : public base::PlatformThread::Delegate {

private:
void ThreadMain() override {
handler_delegate_->RunApplication(application_request_.Pass(),
response_.Pass());
handler_delegate_->RunApplication(std::move(application_request_),
std::move(response_));
handler_thread_->PostTask(FROM_HERE,
base::Bind(termination_callback_, this));
}
Expand All @@ -67,7 +67,7 @@ class ContentHandlerImpl : public ContentHandler {
ContentHandlerImpl(ContentHandlerFactory::Delegate* delegate,
InterfaceRequest<ContentHandler> request)
: delegate_(delegate),
binding_(this, request.Pass()),
binding_(this, std::move(request)),
weak_factory_(this) {}
~ContentHandlerImpl() override {
// We're shutting down and doing cleanup. Cleanup may trigger calls back to
Expand All @@ -87,12 +87,12 @@ class ContentHandlerImpl : public ContentHandler {
InterfaceRequest<Application> application_request,
URLResponsePtr response,
const Callback<void()>& destruct_callback) override {
ApplicationThread* thread = new ApplicationThread(
base::ThreadTaskRunnerHandle::Get(),
base::Bind(&ContentHandlerImpl::OnThreadEnd,
weak_factory_.GetWeakPtr()),
delegate_, application_request.Pass(), response.Pass(),
destruct_callback);
ApplicationThread* thread =
new ApplicationThread(base::ThreadTaskRunnerHandle::Get(),
base::Bind(&ContentHandlerImpl::OnThreadEnd,
weak_factory_.GetWeakPtr()),
delegate_, std::move(application_request),
std::move(response), destruct_callback);
base::PlatformThreadHandle handle;
bool launched = base::PlatformThread::Create(0, thread, &handle);
DCHECK(launched);
Expand Down Expand Up @@ -128,15 +128,15 @@ void ContentHandlerFactory::ManagedDelegate::RunApplication(
InterfaceRequest<Application> application_request,
URLResponsePtr response) {
base::MessageLoop loop(common::MessagePumpMojo::Create());
auto application =
this->CreateApplication(application_request.Pass(), response.Pass());
auto application = this->CreateApplication(std::move(application_request),
std::move(response));
if (application)
loop.Run();
}

void ContentHandlerFactory::Create(ApplicationConnection* connection,
InterfaceRequest<ContentHandler> request) {
new ContentHandlerImpl(delegate_, request.Pass());
new ContentHandlerImpl(delegate_, std::move(request));
}

} // namespace mojo
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef MOJO_APPLICATION_PUBLIC_CPP_LIB_INTERFACE_FACTORY_CONNECTOR_H_
#define MOJO_APPLICATION_PUBLIC_CPP_LIB_INTERFACE_FACTORY_CONNECTOR_H_

#include <utility>

#include "mojo/application/public/cpp/interface_factory.h"
#include "mojo/application/public/cpp/service_connector.h"
#include "mojo/public/cpp/bindings/interface_request.h"
Expand All @@ -23,7 +25,7 @@ class InterfaceFactoryConnector : public ServiceConnector {
const std::string& interface_name,
ScopedMessagePipeHandle client_handle) override {
factory_->Create(application_connection,
MakeRequest<Interface>(client_handle.Pass()));
MakeRequest<Interface>(std::move(client_handle)));
}

private:
Expand Down
6 changes: 4 additions & 2 deletions mojo/application/public/cpp/lib/service_connector_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "mojo/application/public/cpp/lib/service_connector_registry.h"

#include <utility>

#include "mojo/application/public/cpp/service_connector.h"

namespace mojo {
Expand Down Expand Up @@ -46,12 +48,12 @@ void ServiceConnectorRegistry::ConnectToService(
auto iter = name_to_service_connector_.find(interface_name);
if (iter != name_to_service_connector_.end()) {
iter->second->ConnectToService(application_connection, interface_name,
client_handle.Pass());
std::move(client_handle));
return;
}
if (service_connector_) {
service_connector_->ConnectToService(application_connection, interface_name,
client_handle.Pass());
std::move(client_handle));
}
}

Expand Down
10 changes: 5 additions & 5 deletions mojo/application/public/cpp/lib/service_provider_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/application/public/cpp/service_provider_impl.h"
#include <utility>

#include "mojo/application/public/cpp/service_connector.h"
#include "mojo/application/public/cpp/service_provider_impl.h"
#include "mojo/public/cpp/environment/logging.h"

namespace mojo {
Expand All @@ -14,14 +15,13 @@ ServiceProviderImpl::ServiceProviderImpl() : binding_(this) {

ServiceProviderImpl::ServiceProviderImpl(
InterfaceRequest<ServiceProvider> request)
: binding_(this, request.Pass()) {
}
: binding_(this, std::move(request)) {}

ServiceProviderImpl::~ServiceProviderImpl() {
}

void ServiceProviderImpl::Bind(InterfaceRequest<ServiceProvider> request) {
binding_.Bind(request.Pass());
binding_.Bind(std::move(request));
}

void ServiceProviderImpl::ConnectToService(
Expand All @@ -30,7 +30,7 @@ void ServiceProviderImpl::ConnectToService(
// TODO(beng): perhaps take app connection thru ctor so that we can pass
// ApplicationConnection through?
service_connector_registry_.ConnectToService(nullptr, service_name,
client_handle.Pass());
std::move(client_handle));
}

void ServiceProviderImpl::SetServiceConnectorForName(
Expand Down
Loading

0 comments on commit 6196e1f

Please sign in to comment.