summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/chromedriver/net/test_http_server.h2
-rw-r--r--chrome/test/chromedriver/server/chromedriver_server.cc2
-rw-r--r--cloud_print/gcp20/prototype/privet_http_server.h2
-rw-r--r--components/devtools_http_handler/devtools_http_handler.cc2
-rw-r--r--mojo/application/public/cpp/application_impl.h6
-rw-r--r--mojo/application/public/cpp/lib/application_impl.cc2
-rw-r--r--mojo/common/weak_binding_set.h48
-rw-r--r--mojo/common/weak_interface_ptr_set.h9
-rw-r--r--mojo/gles2/command_buffer_client_impl.cc7
-rw-r--r--mojo/gles2/command_buffer_client_impl.h5
-rw-r--r--mojo/runner/child_process.cc7
-rw-r--r--mojo/runner/shell_test_base_unittest.cc23
-rw-r--r--mojo/services/network/http_connection_impl.cc22
-rw-r--r--mojo/services/network/http_connection_impl.h7
-rw-r--r--mojo/services/network/http_server_impl.cc6
-rw-r--r--mojo/services/network/http_server_impl.h7
-rw-r--r--mojo/services/network/tcp_connected_socket_impl.cc2
-rw-r--r--mojo/services/network/tcp_connected_socket_impl.h5
-rw-r--r--mojo/services/network/url_loader_impl.cc2
-rw-r--r--mojo/services/network/url_loader_impl.h5
-rw-r--r--mojo/services/test_service/test_service_impl.cc7
-rw-r--r--mojo/services/test_service/test_service_impl.h5
-rw-r--r--mojo/shell/application_manager_unittest.cc18
-rw-r--r--mojo/shell/content_handler_connection.cc7
-rw-r--r--mojo/shell/content_handler_connection.h8
-rw-r--r--mojo/shell/shell_impl.cc2
-rw-r--r--mojo/shell/shell_impl.h6
-rw-r--r--net/server/http_server.h2
28 files changed, 74 insertions, 152 deletions
diff --git a/chrome/test/chromedriver/net/test_http_server.h b/chrome/test/chromedriver/net/test_http_server.h
index eefb4df..f742ba5 100644
--- a/chrome/test/chromedriver/net/test_http_server.h
+++ b/chrome/test/chromedriver/net/test_http_server.h
@@ -39,7 +39,7 @@ class TestHttpServer : public net::HttpServer::Delegate {
// Creates an http server. By default it accepts WebSockets and echoes
// WebSocket messages back.
TestHttpServer();
- virtual ~TestHttpServer();
+ ~TestHttpServer() override;
// Starts the server. Returns whether it was started successfully.
bool Start();
diff --git a/chrome/test/chromedriver/server/chromedriver_server.cc b/chrome/test/chromedriver/server/chromedriver_server.cc
index 4782eb6..499338e 100644
--- a/chrome/test/chromedriver/server/chromedriver_server.cc
+++ b/chrome/test/chromedriver/server/chromedriver_server.cc
@@ -51,7 +51,7 @@ class HttpServer : public net::HttpServer::Delegate {
: handle_request_func_(handle_request_func),
weak_factory_(this) {}
- virtual ~HttpServer() {}
+ ~HttpServer() override {}
bool Start(uint16 port, bool allow_remote) {
std::string binding_ip = kLocalHostAddress;
diff --git a/cloud_print/gcp20/prototype/privet_http_server.h b/cloud_print/gcp20/prototype/privet_http_server.h
index 5f92d68..18320e3 100644
--- a/cloud_print/gcp20/prototype/privet_http_server.h
+++ b/cloud_print/gcp20/prototype/privet_http_server.h
@@ -131,7 +131,7 @@ class PrivetHttpServer: public net::HttpServer::Delegate {
explicit PrivetHttpServer(Delegate* delegate);
// Destroys the object.
- virtual ~PrivetHttpServer();
+ ~PrivetHttpServer() override;
// Starts HTTP server: start listening port |port| for HTTP requests.
bool Start(uint16 port);
diff --git a/components/devtools_http_handler/devtools_http_handler.cc b/components/devtools_http_handler/devtools_http_handler.cc
index 16e7d04..0080f68 100644
--- a/components/devtools_http_handler/devtools_http_handler.cc
+++ b/components/devtools_http_handler/devtools_http_handler.cc
@@ -98,7 +98,7 @@ class ServerWrapper : net::HttpServer::Delegate {
void WriteActivePortToUserProfile(const base::FilePath& output_directory);
- virtual ~ServerWrapper() {}
+ ~ServerWrapper() override {}
private:
// net::HttpServer::Delegate implementation.
diff --git a/mojo/application/public/cpp/application_impl.h b/mojo/application/public/cpp/application_impl.h
index 20b0733..d3fb716 100644
--- a/mojo/application/public/cpp/application_impl.h
+++ b/mojo/application/public/cpp/application_impl.h
@@ -52,8 +52,7 @@ namespace mojo {
// app.AddService<BarImpl>(&context);
//
//
-class ApplicationImpl : public Application,
- public ErrorHandler {
+class ApplicationImpl : public Application {
public:
// Does not take ownership of |delegate|, which must remain valid for the
// lifetime of ApplicationImpl.
@@ -125,8 +124,7 @@ class ApplicationImpl : public Application,
const String& url) override;
void OnQuitRequested(const Callback<void(bool)>& callback) override;
- // ErrorHandler implementation.
- void OnConnectionError() override;
+ void OnConnectionError();
void ClearConnections();
diff --git a/mojo/application/public/cpp/lib/application_impl.cc b/mojo/application/public/cpp/lib/application_impl.cc
index f1c6e42..da27be1 100644
--- a/mojo/application/public/cpp/lib/application_impl.cc
+++ b/mojo/application/public/cpp/lib/application_impl.cc
@@ -103,7 +103,7 @@ void ApplicationImpl::CloseConnection(ApplicationConnection* connection) {
void ApplicationImpl::Initialize(ShellPtr shell, const mojo::String& url) {
shell_ = shell.Pass();
- shell_.set_error_handler(this);
+ shell_.set_connection_error_handler([this]() { OnConnectionError(); });
url_ = url;
delegate_->Initialize(this);
}
diff --git a/mojo/common/weak_binding_set.h b/mojo/common/weak_binding_set.h
index aeeefe9..66a90b1 100644
--- a/mojo/common/weak_binding_set.h
+++ b/mojo/common/weak_binding_set.h
@@ -19,18 +19,29 @@ class WeakBinding;
// Use this class to manage a set of weak pointers to bindings each of which is
// owned by the pipe they are bound to.
template <typename Interface>
-class WeakBindingSet : public ErrorHandler {
+class WeakBindingSet {
public:
- WeakBindingSet() : error_handler_(nullptr) {}
+ WeakBindingSet() {}
~WeakBindingSet() { CloseAllBindings(); }
- void set_error_handler(ErrorHandler* error_handler) {
+ void set_connection_error_handler(const Closure& error_handler) {
error_handler_ = error_handler;
}
+ // NOTE: Deprecated. Please use the method above.
+ // TODO(yzshen): Remove this method once all callsites are converted.
+ void set_error_handler(ErrorHandler* error_handler) {
+ if (error_handler) {
+ set_connection_error_handler(
+ [error_handler]() { error_handler->OnConnectionError(); });
+ } else {
+ set_connection_error_handler(Closure());
+ }
+ }
+
void AddBinding(Interface* impl, InterfaceRequest<Interface> request) {
auto binding = new WeakBinding<Interface>(impl, request.Pass());
- binding->set_error_handler(this);
+ binding->set_connection_error_handler([this]() { OnConnectionError(); });
bindings_.push_back(binding->GetWeakPtr());
}
@@ -45,8 +56,7 @@ class WeakBindingSet : public ErrorHandler {
bool empty() const { return bindings_.empty(); }
private:
- // ErrorHandler implementation.
- void OnConnectionError() override {
+ void OnConnectionError() {
// Clear any deleted bindings.
bindings_.erase(
std::remove_if(bindings_.begin(), bindings_.end(),
@@ -55,29 +65,27 @@ class WeakBindingSet : public ErrorHandler {
}),
bindings_.end());
- if (error_handler_)
- error_handler_->OnConnectionError();
+ error_handler_.Run();
}
- ErrorHandler* error_handler_;
+ Closure error_handler_;
std::vector<base::WeakPtr<WeakBinding<Interface>>> bindings_;
DISALLOW_COPY_AND_ASSIGN(WeakBindingSet);
};
template <typename Interface>
-class WeakBinding : public ErrorHandler {
+class WeakBinding {
public:
WeakBinding(Interface* impl, InterfaceRequest<Interface> request)
: binding_(impl, request.Pass()),
- error_handler_(nullptr),
weak_ptr_factory_(this) {
- binding_.set_error_handler(this);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
}
- ~WeakBinding() override {}
+ ~WeakBinding() {}
- void set_error_handler(ErrorHandler* error_handler) {
+ void set_connection_error_handler(const Closure& error_handler) {
error_handler_ = error_handler;
}
@@ -87,17 +95,15 @@ class WeakBinding : public ErrorHandler {
void Close() { binding_.Close(); }
- // ErrorHandler implementation.
- void OnConnectionError() override {
- ErrorHandler* error_handler = error_handler_;
+ void OnConnectionError() {
+ Closure error_handler = error_handler_;
delete this;
- if (error_handler)
- error_handler->OnConnectionError();
+ error_handler.Run();
}
private:
- mojo::Binding<Interface> binding_;
- ErrorHandler* error_handler_;
+ Binding<Interface> binding_;
+ Closure error_handler_;
base::WeakPtrFactory<WeakBinding> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WeakBinding);
diff --git a/mojo/common/weak_interface_ptr_set.h b/mojo/common/weak_interface_ptr_set.h
index e2e88a5..4e64534 100644
--- a/mojo/common/weak_interface_ptr_set.h
+++ b/mojo/common/weak_interface_ptr_set.h
@@ -57,13 +57,13 @@ class WeakInterfacePtrSet {
};
template <typename Interface>
-class WeakInterfacePtr : public ErrorHandler {
+class WeakInterfacePtr {
public:
explicit WeakInterfacePtr(InterfacePtr<Interface> ptr)
: ptr_(ptr.Pass()), weak_ptr_factory_(this) {
- ptr_.set_error_handler(this);
+ ptr_.set_connection_error_handler([this]() { delete this; });
}
- ~WeakInterfacePtr() override {}
+ ~WeakInterfacePtr() {}
void Close() { ptr_.reset(); }
@@ -74,9 +74,6 @@ class WeakInterfacePtr : public ErrorHandler {
}
private:
- // ErrorHandler implementation
- void OnConnectionError() override { delete this; }
-
InterfacePtr<Interface> ptr_;
base::WeakPtrFactory<WeakInterfacePtr> weak_ptr_factory_;
diff --git a/mojo/gles2/command_buffer_client_impl.cc b/mojo/gles2/command_buffer_client_impl.cc
index 446cd9f..314efb3 100644
--- a/mojo/gles2/command_buffer_client_impl.cc
+++ b/mojo/gles2/command_buffer_client_impl.cc
@@ -128,7 +128,8 @@ CommandBufferClientImpl::CommandBufferClientImpl(
command_buffer_.Bind(mojo::InterfacePtrInfo<mojo::CommandBuffer>(
command_buffer_handle.Pass(), 0u),
async_waiter);
- command_buffer_.set_error_handler(this);
+ command_buffer_.set_connection_error_handler(
+ [this]() { DidLoseContext(gpu::error::kUnknown); });
}
CommandBufferClientImpl::~CommandBufferClientImpl() {}
@@ -362,10 +363,6 @@ void CommandBufferClientImpl::DidLoseContext(int32_t lost_reason) {
delegate_->ContextLost();
}
-void CommandBufferClientImpl::OnConnectionError() {
- DidLoseContext(gpu::error::kUnknown);
-}
-
void CommandBufferClientImpl::TryUpdateState() {
if (last_state_.error == gpu::error::kNoError)
shared_state()->Read(&last_state_);
diff --git a/mojo/gles2/command_buffer_client_impl.h b/mojo/gles2/command_buffer_client_impl.h
index 765d543..a01c12c 100644
--- a/mojo/gles2/command_buffer_client_impl.h
+++ b/mojo/gles2/command_buffer_client_impl.h
@@ -13,7 +13,6 @@
#include "gpu/command_buffer/client/gpu_control.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"
-#include "mojo/public/cpp/bindings/error_handler.h"
namespace base {
class RunLoop;
@@ -29,7 +28,6 @@ class CommandBufferDelegate {
};
class CommandBufferClientImpl : public mojo::CommandBufferLostContextObserver,
- public mojo::ErrorHandler,
public gpu::CommandBuffer,
public gpu::GpuControl {
public:
@@ -81,9 +79,6 @@ class CommandBufferClientImpl : public mojo::CommandBufferLostContextObserver,
// mojo::CommandBufferLostContextObserver implementation:
void DidLoseContext(int32_t lost_reason) override;
- // mojo::ErrorHandler implementation:
- void OnConnectionError() override;
-
void TryUpdateState();
void MakeProgressAndUpdateState();
diff --git a/mojo/runner/child_process.cc b/mojo/runner/child_process.cc
index 8c2f260..f5adb30 100644
--- a/mojo/runner/child_process.cc
+++ b/mojo/runner/child_process.cc
@@ -170,7 +170,7 @@ class AppContext : public embedder::ProcessDelegate {
// ChildControllerImpl ------------------------------------------------------
-class ChildControllerImpl : public ChildController, public ErrorHandler {
+class ChildControllerImpl : public ChildController {
public:
~ChildControllerImpl() override {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -205,8 +205,7 @@ class ChildControllerImpl : public ChildController, public ErrorHandler {
void Bind(ScopedMessagePipeHandle handle) { binding_.Bind(handle.Pass()); }
- // |ErrorHandler| methods:
- void OnConnectionError() override {
+ void OnConnectionError() {
// A connection error means the connection to the shell is lost. This is not
// recoverable.
LOG(ERROR) << "Connection error to the shell.";
@@ -242,7 +241,7 @@ class ChildControllerImpl : public ChildController, public ErrorHandler {
unblocker_(unblocker),
channel_info_(nullptr),
binding_(this) {
- binding_.set_error_handler(this);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
}
// Callback for |embedder::CreateChannel()|.
diff --git a/mojo/runner/shell_test_base_unittest.cc b/mojo/runner/shell_test_base_unittest.cc
index 7cd7a03..998d55b 100644
--- a/mojo/runner/shell_test_base_unittest.cc
+++ b/mojo/runner/shell_test_base_unittest.cc
@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
-#include "mojo/public/cpp/bindings/error_handler.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/services/test_service/test_request_tracker.mojom.h"
@@ -71,20 +70,6 @@ class ShellTestBaseTest : public ShellTestBase {
TestTrackedRequestServicePtr request_tracking_;
};
-class QuitMessageLoopErrorHandler : public ErrorHandler {
- public:
- QuitMessageLoopErrorHandler() {}
- ~QuitMessageLoopErrorHandler() override {}
-
- // |ErrorHandler| implementation:
- void OnConnectionError() override {
- base::MessageLoop::current()->QuitWhenIdle();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(QuitMessageLoopErrorHandler);
-};
-
// Tests that we can connect to a single service within a single app.
TEST_F(ShellTestBaseTest, ConnectBasic) {
InterfacePtr<TestService> service;
@@ -119,8 +104,8 @@ TEST_F(ShellTestBaseTest, ConnectInvalidService) {
// It may have quit before an error was processed.
if (!test_service.encountered_error()) {
- QuitMessageLoopErrorHandler quitter;
- test_service.set_error_handler(&quitter);
+ test_service.set_connection_error_handler(
+ []() { base::MessageLoop::current()->QuitWhenIdle(); });
message_loop()->Run();
EXPECT_TRUE(test_service.encountered_error());
}
@@ -162,8 +147,8 @@ TEST_F(ShellTestBaseTest, DISABLED_ConnectInvalidServiceNetwork) {
InterfacePtr<TestService> test_service;
ConnectToService(GURL("http://example.com/non_existent_service"),
&test_service);
- QuitMessageLoopErrorHandler quitter;
- test_service.set_error_handler(&quitter);
+ test_service.set_connection_error_handler(
+ []() { base::MessageLoop::current()->QuitWhenIdle(); });
bool was_run = false;
test_service->Ping(SetAndQuit<bool>(&was_run, true));
message_loop()->Run();
diff --git a/mojo/services/network/http_connection_impl.cc b/mojo/services/network/http_connection_impl.cc
index ad3347d..552ddee 100644
--- a/mojo/services/network/http_connection_impl.cc
+++ b/mojo/services/network/http_connection_impl.cc
@@ -86,8 +86,7 @@ class HttpConnectionImpl::SimpleDataPipeReader {
DISALLOW_COPY_AND_ASSIGN(SimpleDataPipeReader);
};
-class HttpConnectionImpl::WebSocketImpl : public WebSocket,
- public ErrorHandler {
+class HttpConnectionImpl::WebSocketImpl : public WebSocket {
public:
// |connection| must outlive this object.
WebSocketImpl(HttpConnectionImpl* connection,
@@ -104,8 +103,8 @@ class HttpConnectionImpl::WebSocketImpl : public WebSocket,
DCHECK(client_);
DCHECK(send_stream_.is_valid());
- binding_.set_error_handler(this);
- client_.set_error_handler(this);
+ binding_.set_connection_error_handler([this]() { Close(); });
+ client_.set_connection_error_handler([this]() { Close(); });
DataPipe data_pipe;
receive_stream_ = data_pipe.producer_handle.Pass();
@@ -174,9 +173,6 @@ class HttpConnectionImpl::WebSocketImpl : public WebSocket,
Close();
}
- // ErrorHandler implementation.
- void OnConnectionError() override { Close(); }
-
void OnFinishedReadingSendStream(uint32_t num_bytes, const char* data) {
DCHECK_GT(pending_send_count_, 0u);
pending_send_count_--;
@@ -264,8 +260,8 @@ HttpConnectionImpl::HttpConnectionImpl(int connection_id,
delegate_(delegate.Pass()),
binding_(this, connection) {
DCHECK(delegate_);
- binding_.set_error_handler(this);
- delegate_.set_error_handler(this);
+ binding_.set_connection_error_handler([this]() { Close(); });
+ delegate_.set_connection_error_handler([this]() { Close(); });
}
HttpConnectionImpl::~HttpConnectionImpl() {
@@ -345,14 +341,6 @@ void HttpConnectionImpl::SetReceiveBufferSize(
callback.Run(MakeNetworkError(net::OK));
}
-void HttpConnectionImpl::OnConnectionError() {
- // This method is called when the proxy side of |binding_| or the impl side of
- // |delegate_| has closed the pipe. Although it is set as error handler for
- // both |binding_| and |delegate_|, it will only be called at most once
- // because when called it closes/resets |binding_| and |delegate_|.
- Close();
-}
-
void HttpConnectionImpl::OnFinishedReadingResponseBody(
HttpResponsePtr response,
SimpleDataPipeReader* reader,
diff --git a/mojo/services/network/http_connection_impl.h b/mojo/services/network/http_connection_impl.h
index 79fc72d..c54218d 100644
--- a/mojo/services/network/http_connection_impl.h
+++ b/mojo/services/network/http_connection_impl.h
@@ -13,7 +13,6 @@
#include "mojo/services/network/public/interfaces/http_connection.mojom.h"
#include "mojo/services/network/public/interfaces/http_message.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
namespace net {
class HttpServerRequestInfo;
@@ -23,8 +22,7 @@ namespace mojo {
class HttpServerImpl;
-class HttpConnectionImpl : public HttpConnection,
- public ErrorHandler {
+class HttpConnectionImpl : public HttpConnection {
public:
// |server| must outlive this object.
HttpConnectionImpl(int connection_id,
@@ -49,8 +47,7 @@ class HttpConnectionImpl : public HttpConnection,
uint32_t size,
const SetReceiveBufferSizeCallback& callback) override;
- // ErrorHandler implementation.
- void OnConnectionError() override;
+ void OnConnectionError();
void OnFinishedReadingResponseBody(HttpResponsePtr response_ptr,
SimpleDataPipeReader* reader,
diff --git a/mojo/services/network/http_server_impl.cc b/mojo/services/network/http_server_impl.cc
index 761c312..ada77f3 100644
--- a/mojo/services/network/http_server_impl.cc
+++ b/mojo/services/network/http_server_impl.cc
@@ -44,7 +44,7 @@ HttpServerImpl::HttpServerImpl(
scoped_ptr<mojo::AppRefCount> app_refcount)
: delegate_(delegate.Pass()), app_refcount_(app_refcount.Pass()) {
DCHECK(delegate_);
- delegate_.set_error_handler(this);
+ delegate_.set_connection_error_handler([this]() { delete this; });
}
HttpServerImpl::~HttpServerImpl() {}
@@ -116,8 +116,4 @@ void HttpServerImpl::OnClose(int connection_id) {
connections_.erase(connection_id);
}
-void HttpServerImpl::OnConnectionError() {
- delete this;
-}
-
} // namespace mojo
diff --git a/mojo/services/network/http_server_impl.h b/mojo/services/network/http_server_impl.h
index 596509a..72a2d79 100644
--- a/mojo/services/network/http_server_impl.h
+++ b/mojo/services/network/http_server_impl.h
@@ -14,7 +14,6 @@
#include "mojo/services/network/public/interfaces/http_server.mojom.h"
#include "mojo/services/network/public/interfaces/net_address.mojom.h"
#include "net/server/http_server.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
namespace net {
class HttpServer;
@@ -24,8 +23,7 @@ namespace mojo {
class HttpConnectionImpl;
-class HttpServerImpl : public net::HttpServer::Delegate,
- public ErrorHandler {
+class HttpServerImpl : public net::HttpServer::Delegate {
public:
static void Create(
NetAddressPtr local_address,
@@ -56,9 +54,6 @@ class HttpServerImpl : public net::HttpServer::Delegate,
void OnWebSocketMessage(int connection_id, const std::string& data) override;
void OnClose(int connection_id) override;
- // ErrorHandler implementation.
- void OnConnectionError() override;
-
HttpServerDelegatePtr delegate_;
scoped_ptr<mojo::AppRefCount> app_refcount_;
scoped_ptr<net::HttpServer> server_;
diff --git a/mojo/services/network/tcp_connected_socket_impl.cc b/mojo/services/network/tcp_connected_socket_impl.cc
index 8241a18..44fba13 100644
--- a/mojo/services/network/tcp_connected_socket_impl.cc
+++ b/mojo/services/network/tcp_connected_socket_impl.cc
@@ -23,7 +23,7 @@ TCPConnectedSocketImpl::TCPConnectedSocketImpl(
app_refcount_(app_refcount.Pass()),
weak_ptr_factory_(this) {
// Queue up async communication.
- binding_.set_error_handler(this);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
ListenForReceivePeerClosed();
ListenForSendPeerClosed();
ReceiveMore();
diff --git a/mojo/services/network/tcp_connected_socket_impl.h b/mojo/services/network/tcp_connected_socket_impl.h
index 403b20f..0327e47 100644
--- a/mojo/services/network/tcp_connected_socket_impl.h
+++ b/mojo/services/network/tcp_connected_socket_impl.h
@@ -18,7 +18,7 @@ namespace mojo {
class MojoToNetPendingBuffer;
class NetToMojoPendingBuffer;
-class TCPConnectedSocketImpl : public TCPConnectedSocket, public ErrorHandler {
+class TCPConnectedSocketImpl : public TCPConnectedSocket {
public:
TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket,
ScopedDataPipeConsumerHandle send_stream,
@@ -28,8 +28,7 @@ class TCPConnectedSocketImpl : public TCPConnectedSocket, public ErrorHandler {
~TCPConnectedSocketImpl() override;
private:
- // ErrorHandler methods:
- void OnConnectionError() override;
+ void OnConnectionError();
// "Receiving" in this context means reading from TCPSocket and writing to
// the Mojo receive_stream.
diff --git a/mojo/services/network/url_loader_impl.cc b/mojo/services/network/url_loader_impl.cc
index f9590f1..002f2ee 100644
--- a/mojo/services/network/url_loader_impl.cc
+++ b/mojo/services/network/url_loader_impl.cc
@@ -142,7 +142,7 @@ URLLoaderImpl::URLLoaderImpl(NetworkContext* context,
binding_(this, request.Pass()),
app_refcount_(app_refcount.Pass()),
weak_ptr_factory_(this) {
- binding_.set_error_handler(this);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
context_->RegisterURLLoader(this);
}
diff --git a/mojo/services/network/url_loader_impl.h b/mojo/services/network/url_loader_impl.h
index 44de533..0413487 100644
--- a/mojo/services/network/url_loader_impl.h
+++ b/mojo/services/network/url_loader_impl.h
@@ -13,7 +13,6 @@
#include "net/base/net_errors.h"
#include "net/url_request/url_request.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
namespace mojo {
@@ -22,7 +21,6 @@ class NetworkContext;
class NetToMojoPendingBuffer;
class URLLoaderImpl : public URLLoader,
- public ErrorHandler,
public net::URLRequest::Delegate {
public:
URLLoaderImpl(NetworkContext* context,
@@ -40,8 +38,7 @@ class URLLoaderImpl : public URLLoader,
void FollowRedirect(const Callback<void(URLResponsePtr)>& callback) override;
void QueryStatus(const Callback<void(URLLoaderStatusPtr)>& callback) override;
- // ErrorHandler methods:
- void OnConnectionError() override;
+ void OnConnectionError();
// net::URLRequest::Delegate methods:
void OnReceivedRedirect(net::URLRequest* url_request,
diff --git a/mojo/services/test_service/test_service_impl.cc b/mojo/services/test_service/test_service_impl.cc
index 4195e50..44d1818 100644
--- a/mojo/services/test_service/test_service_impl.cc
+++ b/mojo/services/test_service/test_service_impl.cc
@@ -21,16 +21,13 @@ TestServiceImpl::TestServiceImpl(ApplicationImpl* app_impl,
: application_(application),
app_impl_(app_impl),
binding_(this, request.Pass()) {
- binding_.set_error_handler(this);
+ binding_.set_connection_error_handler(
+ [this]() { application_->ReleaseRef(); });
}
TestServiceImpl::~TestServiceImpl() {
}
-void TestServiceImpl::OnConnectionError() {
- application_->ReleaseRef();
-}
-
void TestServiceImpl::Ping(const mojo::Callback<void()>& callback) {
if (tracking_)
tracking_->RecordNewRequest();
diff --git a/mojo/services/test_service/test_service_impl.h b/mojo/services/test_service/test_service_impl.h
index 475a95b..c6680a2 100644
--- a/mojo/services/test_service/test_service_impl.h
+++ b/mojo/services/test_service/test_service_impl.h
@@ -17,7 +17,7 @@ namespace test {
class TrackedService;
class TestServiceApplication;
-class TestServiceImpl : public TestService, ErrorHandler {
+class TestServiceImpl : public TestService {
public:
TestServiceImpl(ApplicationImpl* app_impl,
TestServiceApplication* application,
@@ -31,9 +31,6 @@ class TestServiceImpl : public TestService, ErrorHandler {
const mojo::Callback<void(int64_t)>& callback) override;
void StartTrackingRequests(const mojo::Callback<void()>& callback) override;
- // ErrorHandler methods:
- void OnConnectionError() override;
-
private:
TestServiceApplication* const application_;
ApplicationImpl* const app_impl_;
diff --git a/mojo/shell/application_manager_unittest.cc b/mojo/shell/application_manager_unittest.cc
index c5f883e..7e6dd31 100644
--- a/mojo/shell/application_manager_unittest.cc
+++ b/mojo/shell/application_manager_unittest.cc
@@ -70,20 +70,6 @@ void QuitClosure(bool* value) {
base::MessageLoop::current()->QuitWhenIdle();
}
-class QuitMessageLoopErrorHandler : public ErrorHandler {
- public:
- QuitMessageLoopErrorHandler() {}
- ~QuitMessageLoopErrorHandler() override {}
-
- // |ErrorHandler| implementation:
- void OnConnectionError() override {
- base::MessageLoop::current()->QuitWhenIdle();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(QuitMessageLoopErrorHandler);
-};
-
class TestServiceImpl : public TestService {
public:
TestServiceImpl(TestContext* context, InterfaceRequest<TestService> request)
@@ -700,8 +686,8 @@ TEST_F(ApplicationManagerTest, NoServiceNoLoad) {
// ApplicationManager, so this cannot succeed (but also shouldn't crash).
TestCPtr c;
application_manager_->ConnectToService(GURL(kTestAURLString), &c);
- QuitMessageLoopErrorHandler quitter;
- c.set_error_handler(&quitter);
+ c.set_connection_error_handler(
+ []() { base::MessageLoop::current()->QuitWhenIdle(); });
loop_.Run();
EXPECT_TRUE(c.encountered_error());
diff --git a/mojo/shell/content_handler_connection.cc b/mojo/shell/content_handler_connection.cc
index 2de5797..37b3b4ef 100644
--- a/mojo/shell/content_handler_connection.cc
+++ b/mojo/shell/content_handler_connection.cc
@@ -28,7 +28,8 @@ ContentHandlerConnection::ContentHandlerConnection(
content_handler_.Bind(
InterfacePtrInfo<ContentHandler>(pipe.handle0.Pass(), 0u));
services->ConnectToService(ContentHandler::Name_, pipe.handle1.Pass());
- content_handler_.set_error_handler(this);
+ content_handler_.set_connection_error_handler(
+ [this]() { CloseConnection(); });
}
void ContentHandlerConnection::CloseConnection() {
@@ -45,9 +46,5 @@ ContentHandlerConnection::~ContentHandlerConnection() {
DCHECK(connection_closed_);
}
-void ContentHandlerConnection::OnConnectionError() {
- CloseConnection();
-}
-
} // namespace shell
} // namespace mojo
diff --git a/mojo/shell/content_handler_connection.h b/mojo/shell/content_handler_connection.h
index af70493..749e6b4 100644
--- a/mojo/shell/content_handler_connection.h
+++ b/mojo/shell/content_handler_connection.h
@@ -8,7 +8,6 @@
#include <string>
#include "mojo/application/public/interfaces/content_handler.mojom.h"
-#include "mojo/public/cpp/bindings/error_handler.h"
#include "url/gurl.h"
namespace mojo {
@@ -22,7 +21,7 @@ class ApplicationManager;
// A ContentHandlerConnection manages its own lifetime and cannot be used with
// a scoped_ptr to avoid reentrant calls into ApplicationManager late in
// destruction.
-class ContentHandlerConnection : public ErrorHandler {
+class ContentHandlerConnection {
public:
ContentHandlerConnection(ApplicationManager* manager,
const GURL& content_handler_url,
@@ -39,10 +38,7 @@ class ContentHandlerConnection : public ErrorHandler {
}
private:
- ~ContentHandlerConnection() override;
-
- // ErrorHandler implementation:
- void OnConnectionError() override;
+ ~ContentHandlerConnection();
ApplicationManager* manager_;
GURL content_handler_url_;
diff --git a/mojo/shell/shell_impl.cc b/mojo/shell/shell_impl.cc
index 4b10471..5f1a782 100644
--- a/mojo/shell/shell_impl.cc
+++ b/mojo/shell/shell_impl.cc
@@ -30,7 +30,7 @@ ShellImpl::ShellImpl(ApplicationPtr application,
application_(application.Pass()),
binding_(this),
queue_requests_(false) {
- binding_.set_error_handler(this);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
}
ShellImpl::~ShellImpl() {
diff --git a/mojo/shell/shell_impl.h b/mojo/shell/shell_impl.h
index c6a761a..8b4dfd8 100644
--- a/mojo/shell/shell_impl.h
+++ b/mojo/shell/shell_impl.h
@@ -9,7 +9,6 @@
#include "mojo/application/public/interfaces/application.mojom.h"
#include "mojo/application/public/interfaces/shell.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/public/cpp/bindings/error_handler.h"
#include "mojo/shell/identity.h"
#include "url/gurl.h"
@@ -18,7 +17,7 @@ namespace shell {
class ApplicationManager;
-class ShellImpl : public Shell, public ErrorHandler {
+class ShellImpl : public Shell {
public:
ShellImpl(ApplicationPtr application,
ApplicationManager* manager,
@@ -45,8 +44,7 @@ class ShellImpl : public Shell, public ErrorHandler {
ServiceProviderPtr exposed_services) override;
void QuitApplication() override;
- // ErrorHandler implementation:
- void OnConnectionError() override;
+ void OnConnectionError();
void OnQuitRequestedResult(bool can_quit);
diff --git a/net/server/http_server.h b/net/server/http_server.h
index 89a4b45..b8be0ed 100644
--- a/net/server/http_server.h
+++ b/net/server/http_server.h
@@ -30,6 +30,8 @@ class HttpServer {
// destroy the HttpServer in any of these callbacks.
class Delegate {
public:
+ virtual ~Delegate() {}
+
virtual void OnConnect(int connection_id) = 0;
virtual void OnHttpRequest(int connection_id,
const HttpServerRequestInfo& info) = 0;