Roll mojo SDK to 734c6e1652ff2f3b696e441722838f453f4f9b42
- Remove usage of interface_impl.h
- Implements URLRequest::only_from_cache
R=ppi@chromium.org, viettrungluu@chromium.org
Review URL: https://codereview.chromium.org/1227373002 .
diff --git a/DEPS b/DEPS
index 8ef841f..1da218b 100644
--- a/DEPS
+++ b/DEPS
@@ -65,7 +65,7 @@
Var('chromium_git') + '/chromium/deps/icu.git' + '@' + '7c81740601355556e630da515b74d889ba2f8d08',
'src/third_party/mojo/src/mojo/public':
- Var('chromium_git') + '/external/github.com/domokit/mojo_sdk.git' + '@' + 'ab3f523596234e747231166b5142f41d3869861a',
+ Var('chromium_git') + '/external/github.com/domokit/mojo_sdk.git' + '@' + 'ca51a4809257c8518f224ef5af982e136db1dda0',
'src/tools/grit':
Var('chromium_git') + '/external/grit-i18n.git' + '@' + 'c1b1591a05209c1ad467e845ba8543c22f9072af', # from svn revision 189
diff --git a/mojo/common/weak_interface_ptr_set.h b/mojo/common/weak_interface_ptr_set.h
index e2e88a5..f93c025 100644
--- a/mojo/common/weak_interface_ptr_set.h
+++ b/mojo/common/weak_interface_ptr_set.h
@@ -7,63 +7,28 @@
#include <vector>
+#include "base/logging.h"
#include "base/memory/weak_ptr.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr.h"
+#include "mojo/public/cpp/bindings/interface_ptr.h"
namespace mojo {
+namespace internal {
+
+// TODO(vtl): This name of this class is a little odd -- it's not a "weak
+// pointer", but a wrapper around InterfacePtr that owns itself and can vend
+// weak pointers to itself. Probably, with connection error callbacks instead of
+// ErrorHandlers, this class is unneeded, and WeakInterfacePtrSet can simply
+// own/remove interface pointers as connection errors occur.
+// https://github.com/domokit/mojo/issues/311
template <typename Interface>
-class WeakInterfacePtr;
-
-template <typename Interface>
-class WeakInterfacePtrSet {
- public:
- WeakInterfacePtrSet() {}
- ~WeakInterfacePtrSet() { CloseAll(); }
-
- void AddInterfacePtr(InterfacePtr<Interface> ptr) {
- auto weak_interface_ptr = new WeakInterfacePtr<Interface>(ptr.Pass());
- ptrs_.push_back(weak_interface_ptr->GetWeakPtr());
- ClearNullInterfacePtrs();
- }
-
- template <typename FunctionType>
- void ForAllPtrs(FunctionType function) {
- for (const auto& it : ptrs_) {
- if (it)
- function(it->get());
- }
- ClearNullInterfacePtrs();
- }
-
- void CloseAll() {
- for (const auto& it : ptrs_) {
- if (it)
- it->Close();
- }
- ptrs_.clear();
- }
-
- private:
- using WPWIPI = base::WeakPtr<WeakInterfacePtr<Interface>>;
-
- void ClearNullInterfacePtrs() {
- ptrs_.erase(std::remove_if(ptrs_.begin(), ptrs_.end(), [](const WPWIPI& p) {
- return p.get() == nullptr;
- }), ptrs_.end());
- }
-
- std::vector<WPWIPI> ptrs_;
-};
-
-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,15 +39,74 @@
}
private:
- // ErrorHandler implementation
- void OnConnectionError() override { delete this; }
-
InterfacePtr<Interface> ptr_;
base::WeakPtrFactory<WeakInterfacePtr> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WeakInterfacePtr);
};
+} // namespace internal
+
+// A WeakInterfacePtrSet contains a collection of InterfacePtrs
+// that are automatically removed from the collection and destroyed
+// when their associated MessagePipe experiences a connection error.
+// When the set is destroyed all of the MessagePipes will be closed.
+// TODO(rudominer) Rename this class since the ownership of the elements
+// is not "weak" from the point of view of the client.
+template <typename Interface>
+class WeakInterfacePtrSet {
+ public:
+ WeakInterfacePtrSet() {}
+ ~WeakInterfacePtrSet() { CloseAll(); }
+
+ // |ptr| must be bound to a message pipe.
+ void AddInterfacePtr(InterfacePtr<Interface> ptr) {
+ DCHECK(ptr.is_bound());
+ auto weak_interface_ptr =
+ new internal::WeakInterfacePtr<Interface>(ptr.Pass());
+ ptrs_.push_back(weak_interface_ptr->GetWeakPtr());
+ ClearNullInterfacePtrs();
+ }
+
+ // Applies |function| to each of the InterfacePtrs in the set.
+ template <typename FunctionType>
+ void ForAllPtrs(FunctionType function) {
+ for (const auto& it : ptrs_) {
+ if (it)
+ function(it->get());
+ }
+ ClearNullInterfacePtrs();
+ }
+
+ // Closes the MessagePipe associated with each of the InterfacePtrs in
+ // this set and clears the set.
+ void CloseAll() {
+ for (const auto& it : ptrs_) {
+ if (it)
+ it->Close();
+ }
+ ptrs_.clear();
+ }
+
+ // TODO(rudominer) After reworking this class and eliminating the method
+ // ClearNullInterfacePtrs, this method should become const.
+ size_t size() {
+ ClearNullInterfacePtrs();
+ return ptrs_.size();
+ }
+
+ private:
+ using WPWIPI = base::WeakPtr<internal::WeakInterfacePtr<Interface>>;
+
+ void ClearNullInterfacePtrs() {
+ ptrs_.erase(std::remove_if(ptrs_.begin(), ptrs_.end(), [](const WPWIPI& p) {
+ return p.get() == nullptr;
+ }), ptrs_.end());
+ }
+
+ std::vector<WPWIPI> ptrs_;
+};
+
} // namespace mojo
#endif // MOJO_COMMON_WEAK_INTERFACE_PTR_SET_H_
diff --git a/mojo/services/network/cookie_store_impl.cc b/mojo/services/network/cookie_store_impl.cc
index 6882435..ca64841 100644
--- a/mojo/services/network/cookie_store_impl.cc
+++ b/mojo/services/network/cookie_store_impl.cc
@@ -24,8 +24,10 @@
} // namespace
-CookieStoreImpl::CookieStoreImpl(NetworkContext* context, const GURL& origin)
- : context_(context), origin_(origin) {
+CookieStoreImpl::CookieStoreImpl(InterfaceRequest<CookieStore> request,
+ NetworkContext* context,
+ const GURL& origin)
+ : binding_(this, request.Pass()), context_(context), origin_(origin) {
}
CookieStoreImpl::~CookieStoreImpl() {
diff --git a/mojo/services/network/cookie_store_impl.h b/mojo/services/network/cookie_store_impl.h
index e3e9711..9a9f65f 100644
--- a/mojo/services/network/cookie_store_impl.h
+++ b/mojo/services/network/cookie_store_impl.h
@@ -6,14 +6,17 @@
#define MOJO_SERVICES_NETWORK_COOKIE_STORE_IMPL_H_
#include "mojo/services/network/public/interfaces/cookie_store.mojom.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
#include "url/gurl.h"
namespace mojo {
class NetworkContext;
-class CookieStoreImpl : public InterfaceImpl<CookieStore> {
+class CookieStoreImpl : public CookieStore {
public:
- CookieStoreImpl(NetworkContext* context, const GURL& origin);
+ CookieStoreImpl(InterfaceRequest<CookieStore> request,
+ NetworkContext* context,
+ const GURL& origin);
~CookieStoreImpl() override;
private:
@@ -23,6 +26,7 @@
const String& cookie,
const Callback<void(bool)>& callback) override;
+ mojo::StrongBinding<CookieStore> binding_;
NetworkContext* context_;
GURL origin_;
diff --git a/mojo/services/network/http_connection_impl.cc b/mojo/services/network/http_connection_impl.cc
index 77d7a91..1fb8a44 100644
--- a/mojo/services/network/http_connection_impl.cc
+++ b/mojo/services/network/http_connection_impl.cc
@@ -85,8 +85,7 @@
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,
@@ -103,8 +102,8 @@
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();
@@ -173,9 +172,6 @@
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_--;
@@ -263,8 +259,8 @@
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() {
@@ -344,14 +340,6 @@
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..526a688 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 @@
class HttpServerImpl;
-class HttpConnectionImpl : public HttpConnection,
- public ErrorHandler {
+class HttpConnectionImpl : public HttpConnection {
public:
// |server| must outlive this object.
HttpConnectionImpl(int connection_id,
@@ -49,9 +47,6 @@
uint32_t size,
const SetReceiveBufferSizeCallback& callback) override;
- // ErrorHandler implementation.
- void OnConnectionError() override;
-
void OnFinishedReadingResponseBody(HttpResponsePtr response_ptr,
SimpleDataPipeReader* reader,
scoped_ptr<std::string> body);
diff --git a/mojo/services/network/http_server_impl.cc b/mojo/services/network/http_server_impl.cc
index 599b3df..c7ebddd 100644
--- a/mojo/services/network/http_server_impl.cc
+++ b/mojo/services/network/http_server_impl.cc
@@ -40,7 +40,7 @@
HttpServerImpl::HttpServerImpl(HttpServerDelegatePtr delegate)
: delegate_(delegate.Pass()) {
DCHECK(delegate_);
- delegate_.set_error_handler(this);
+ delegate_.set_connection_error_handler([this]() { delete this; });
}
HttpServerImpl::~HttpServerImpl() {}
@@ -112,8 +112,4 @@
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 01e26cc..67192da 100644
--- a/mojo/services/network/http_server_impl.h
+++ b/mojo/services/network/http_server_impl.h
@@ -13,7 +13,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;
@@ -23,8 +22,7 @@
class HttpConnectionImpl;
-class HttpServerImpl : public net::HttpServer::Delegate,
- public ErrorHandler {
+class HttpServerImpl : public net::HttpServer::Delegate {
public:
static void Create(
NetAddressPtr local_address,
@@ -39,7 +37,7 @@
// notified that |delegate|'s pipe is closed. Deleting the object directly
// before that is okay, too.
explicit HttpServerImpl(HttpServerDelegatePtr delegate);
- ~HttpServerImpl() override;
+ virtual ~HttpServerImpl();
int Start(NetAddressPtr local_address);
NetAddressPtr GetLocalAddress() const;
@@ -53,9 +51,6 @@
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<net::HttpServer> server_;
diff --git a/mojo/services/network/network_service_delegate.cc b/mojo/services/network/network_service_delegate.cc
index 1608ab6..76e0b69 100644
--- a/mojo/services/network/network_service_delegate.cc
+++ b/mojo/services/network/network_service_delegate.cc
@@ -40,6 +40,5 @@
void NetworkServiceDelegate::Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::NetworkService> request) {
- mojo::BindToRequest(new mojo::NetworkServiceImpl(connection, context_.get()),
- &request);
+ new mojo::NetworkServiceImpl(request.Pass(), connection, context_.get());
}
diff --git a/mojo/services/network/network_service_impl.cc b/mojo/services/network/network_service_impl.cc
index b86bcec..6026686 100644
--- a/mojo/services/network/network_service_impl.cc
+++ b/mojo/services/network/network_service_impl.cc
@@ -16,9 +16,11 @@
namespace mojo {
-NetworkServiceImpl::NetworkServiceImpl(ApplicationConnection* connection,
+NetworkServiceImpl::NetworkServiceImpl(InterfaceRequest<NetworkService> request,
+ ApplicationConnection* connection,
NetworkContext* context)
- : context_(context),
+ : binding_(this, request.Pass()),
+ context_(context),
origin_(GURL(connection->GetRemoteApplicationURL()).GetOrigin()) {
}
@@ -41,25 +43,27 @@
}
void NetworkServiceImpl::GetCookieStore(InterfaceRequest<CookieStore> store) {
- BindToRequest(new CookieStoreImpl(context_, origin_), &store);
+ new CookieStoreImpl(store.Pass(), context_, origin_);
}
void NetworkServiceImpl::CreateWebSocket(InterfaceRequest<WebSocket> socket) {
- BindToRequest(new WebSocketImpl(context_), &socket);
+ new WebSocketImpl(socket.Pass(), context_);
}
void NetworkServiceImpl::CreateTCPBoundSocket(
NetAddressPtr local_address,
InterfaceRequest<TCPBoundSocket> bound_socket,
const CreateTCPBoundSocketCallback& callback) {
- scoped_ptr<TCPBoundSocketImpl> bound(new TCPBoundSocketImpl);
+ scoped_ptr<TCPBoundSocketImpl> bound(
+ new TCPBoundSocketImpl(bound_socket.Pass()));
int net_error = bound->Bind(local_address.Pass());
if (net_error != net::OK) {
callback.Run(MakeNetworkError(net_error), NetAddressPtr());
return;
}
NetAddressPtr resulting_local_address(bound->GetLocalAddress());
- BindToRequest(bound.release(), &bound_socket);
+ // Release the implementation and let its lifecycle be managed by the pipe.
+ ignore_result(bound.release());
callback.Run(MakeNetworkError(net::OK), resulting_local_address.Pass());
}
diff --git a/mojo/services/network/network_service_impl.h b/mojo/services/network/network_service_impl.h
index 3a7ac23..360d9f0 100644
--- a/mojo/services/network/network_service_impl.h
+++ b/mojo/services/network/network_service_impl.h
@@ -8,16 +8,17 @@
#include "base/compiler_specific.h"
#include "mojo/common/weak_interface_ptr_set.h"
#include "mojo/services/network/public/interfaces/network_service.mojom.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
#include "url/gurl.h"
namespace mojo {
class ApplicationConnection;
class NetworkContext;
-class NetworkServiceImpl : public InterfaceImpl<NetworkService> {
+class NetworkServiceImpl : public NetworkService {
public:
- NetworkServiceImpl(ApplicationConnection* connection,
+ NetworkServiceImpl(InterfaceRequest<NetworkService> request,
+ ApplicationConnection* connection,
NetworkContext* context);
~NetworkServiceImpl() override;
@@ -45,6 +46,7 @@
InterfaceRequest<HostResolver> host_resolver) override;
private:
+ StrongBinding<NetworkService> binding_;
NetworkContext* context_;
GURL origin_;
WeakInterfacePtrSet<URLLoaderInterceptorFactory>
diff --git a/mojo/services/network/tcp_bound_socket_impl.cc b/mojo/services/network/tcp_bound_socket_impl.cc
index b776304..31fd54d 100644
--- a/mojo/services/network/tcp_bound_socket_impl.cc
+++ b/mojo/services/network/tcp_bound_socket_impl.cc
@@ -12,7 +12,8 @@
namespace mojo {
-TCPBoundSocketImpl::TCPBoundSocketImpl() {
+TCPBoundSocketImpl::TCPBoundSocketImpl(InterfaceRequest<TCPBoundSocket> request)
+ : binding_(this, request.Pass()) {
}
TCPBoundSocketImpl::~TCPBoundSocketImpl() {
@@ -63,7 +64,7 @@
}
// The server socket object takes ownership of the socket.
- BindToRequest(new TCPServerSocketImpl(socket_.Pass()), &server);
+ new TCPServerSocketImpl(server.Pass(), socket_.Pass());
callback.Run(MakeNetworkError(net::OK));
}
diff --git a/mojo/services/network/tcp_bound_socket_impl.h b/mojo/services/network/tcp_bound_socket_impl.h
index e5e1b6c..4685409 100644
--- a/mojo/services/network/tcp_bound_socket_impl.h
+++ b/mojo/services/network/tcp_bound_socket_impl.h
@@ -8,13 +8,13 @@
#include "base/memory/scoped_ptr.h"
#include "mojo/services/network/public/interfaces/tcp_bound_socket.mojom.h"
#include "net/socket/tcp_socket.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
namespace mojo {
-class TCPBoundSocketImpl : public InterfaceImpl<TCPBoundSocket> {
+class TCPBoundSocketImpl : public TCPBoundSocket {
public:
- TCPBoundSocketImpl();
+ explicit TCPBoundSocketImpl(InterfaceRequest<TCPBoundSocket> request);
~TCPBoundSocketImpl() override;
// Does the actual binding. Returns a net error code. On net::OK, the bound
@@ -38,6 +38,7 @@
private:
void OnConnected(int result);
+ StrongBinding<TCPBoundSocket> binding_;
scoped_ptr<net::TCPSocket> socket_;
// Valid when waiting for a connect callback.
diff --git a/mojo/services/network/tcp_connected_socket_impl.cc b/mojo/services/network/tcp_connected_socket_impl.cc
index 7a46529..8675a5e 100644
--- a/mojo/services/network/tcp_connected_socket_impl.cc
+++ b/mojo/services/network/tcp_connected_socket_impl.cc
@@ -22,7 +22,7 @@
send_more_posted_(false),
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 0fed4d0..6b6460e 100644
--- a/mojo/services/network/tcp_connected_socket_impl.h
+++ b/mojo/services/network/tcp_connected_socket_impl.h
@@ -17,7 +17,7 @@
class MojoToNetPendingBuffer;
class NetToMojoPendingBuffer;
-class TCPConnectedSocketImpl : public TCPConnectedSocket, public ErrorHandler {
+class TCPConnectedSocketImpl : public TCPConnectedSocket {
public:
TCPConnectedSocketImpl(scoped_ptr<net::TCPSocket> socket,
ScopedDataPipeConsumerHandle send_stream,
@@ -26,9 +26,6 @@
~TCPConnectedSocketImpl() override;
private:
- // ErrorHandler methods:
- void OnConnectionError() override;
-
// "Receiving" in this context means reading from TCPSocket and writing to
// the Mojo receive_stream.
void ReceiveMore();
@@ -48,6 +45,7 @@
void ListenForSendPeerClosed();
void OnSendDataPipeClosed(MojoResult result);
+ void OnConnectionError();
void DeleteIfNeeded();
scoped_ptr<net::TCPSocket> socket_;
diff --git a/mojo/services/network/tcp_server_socket_impl.cc b/mojo/services/network/tcp_server_socket_impl.cc
index 96ec1e3..5d681a3 100644
--- a/mojo/services/network/tcp_server_socket_impl.cc
+++ b/mojo/services/network/tcp_server_socket_impl.cc
@@ -11,8 +11,10 @@
namespace mojo {
-TCPServerSocketImpl::TCPServerSocketImpl(scoped_ptr<net::TCPSocket> socket)
- : socket_(socket.Pass()) {
+TCPServerSocketImpl::TCPServerSocketImpl(
+ InterfaceRequest<TCPServerSocket> request,
+ scoped_ptr<net::TCPSocket> socket)
+ : binding_(this, request.Pass()), socket_(socket.Pass()) {
}
TCPServerSocketImpl::~TCPServerSocketImpl() {
diff --git a/mojo/services/network/tcp_server_socket_impl.h b/mojo/services/network/tcp_server_socket_impl.h
index 0039f8d..324697c 100644
--- a/mojo/services/network/tcp_server_socket_impl.h
+++ b/mojo/services/network/tcp_server_socket_impl.h
@@ -9,16 +9,17 @@
#include "mojo/services/network/public/interfaces/tcp_server_socket.mojom.h"
#include "net/base/ip_endpoint.h"
#include "net/socket/tcp_socket.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
namespace mojo {
-class TCPServerSocketImpl : public InterfaceImpl<TCPServerSocket> {
+class TCPServerSocketImpl : public TCPServerSocket {
public:
typedef Callback<void(NetworkErrorPtr, NetAddressPtr)> AcceptCallback;
// Passed ownership of a socket already in listening mode.
- explicit TCPServerSocketImpl(scoped_ptr<net::TCPSocket> socket);
+ TCPServerSocketImpl(InterfaceRequest<TCPServerSocket> request,
+ scoped_ptr<net::TCPSocket> socket);
~TCPServerSocketImpl() override;
// TCPServerSocket.
@@ -30,6 +31,7 @@
private:
void OnAcceptCompleted(int result);
+ StrongBinding<TCPServerSocket> binding_;
scoped_ptr<net::TCPSocket> socket_;
// Non-null when accept is pending.
diff --git a/mojo/services/network/udp_socket_impl.h b/mojo/services/network/udp_socket_impl.h
index c2070bf..0af406e 100644
--- a/mojo/services/network/udp_socket_impl.h
+++ b/mojo/services/network/udp_socket_impl.h
@@ -12,7 +12,6 @@
#include "mojo/services/network/public/interfaces/udp_socket.mojom.h"
#include "net/base/ip_endpoint.h"
#include "net/udp/udp_socket.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
namespace net {
diff --git a/mojo/services/network/url_loader_impl.cc b/mojo/services/network/url_loader_impl.cc
index 10e497a..bda30e5 100644
--- a/mojo/services/network/url_loader_impl.cc
+++ b/mojo/services/network/url_loader_impl.cc
@@ -268,10 +268,10 @@
current_fetcher_id_(0),
binding_(this, request.Pass()) {
for (auto& interceptor : interceptors_) {
- interceptor.set_error_handler(this);
+ interceptor.set_connection_error_handler([this]() { OnConnectionError(); });
}
interceptor_index_ = interceptors_.size() - 1;
- binding_.set_error_handler(this);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
context_->RegisterURLLoader(this);
}
@@ -336,12 +336,6 @@
callback.Run(status.Pass());
}
-void URLLoaderImpl::OnConnectionError() {
- binding_.Close();
- if (body_fetchers_.empty())
- delete this;
-}
-
void URLLoaderImpl::OnReceivedRedirect(net::URLRequest* url_request,
const net::RedirectInfo& redirect_info,
bool* defer_redirect) {
@@ -399,6 +393,12 @@
DCHECK(false);
}
+void URLLoaderImpl::OnConnectionError() {
+ binding_.Close();
+ if (body_fetchers_.empty())
+ delete this;
+}
+
void URLLoaderImpl::SendError(
int error_code,
const Callback<void(URLResponsePtr)>& callback) {
@@ -536,8 +536,13 @@
url_request_->set_upload(make_scoped_ptr<net::UploadDataStream>(
new net::ElementsUploadDataStream(element_readers.Pass(), 0)));
}
+ int load_flags = 0;
if (request->bypass_cache)
- url_request_->SetLoadFlags(net::LOAD_BYPASS_CACHE);
+ load_flags |= net::LOAD_BYPASS_CACHE;
+ if (request->only_from_cache)
+ load_flags |= net::LOAD_ONLY_FROM_CACHE;
+ if (load_flags)
+ url_request_->SetLoadFlags(load_flags);
response_body_buffer_size_ = request->response_body_buffer_size;
auto_follow_redirects_ = request->auto_follow_redirects;
diff --git a/mojo/services/network/url_loader_impl.h b/mojo/services/network/url_loader_impl.h
index bfcbbfe..f25974c 100644
--- a/mojo/services/network/url_loader_impl.h
+++ b/mojo/services/network/url_loader_impl.h
@@ -13,8 +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 +20,6 @@
class NetToMojoPendingBuffer;
class URLLoaderImpl : public URLLoader,
- public ErrorHandler,
public net::URLRequest::Delegate {
public:
URLLoaderImpl(NetworkContext* context,
@@ -42,9 +39,6 @@
void FollowRedirect(const Callback<void(URLResponsePtr)>& callback) override;
void QueryStatus(const Callback<void(URLLoaderStatusPtr)>& callback) override;
- // ErrorHandler methods:
- void OnConnectionError() override;
-
// net::URLRequest::Delegate methods:
void OnReceivedRedirect(net::URLRequest* url_request,
const net::RedirectInfo& redirect_info,
@@ -52,6 +46,7 @@
void OnResponseStarted(net::URLRequest* url_request) override;
void OnReadCompleted(net::URLRequest* url_request, int bytes_read) override;
+ void OnConnectionError();
void SendError(
int error,
const Callback<void(URLResponsePtr)>& callback);
diff --git a/mojo/services/network/web_socket_impl.cc b/mojo/services/network/web_socket_impl.cc
index 0513be6..7b1a37e 100644
--- a/mojo/services/network/web_socket_impl.cc
+++ b/mojo/services/network/web_socket_impl.cc
@@ -177,7 +177,9 @@
} // namespace mojo
-WebSocketImpl::WebSocketImpl(NetworkContext* context) : context_(context) {
+WebSocketImpl::WebSocketImpl(InterfaceRequest<WebSocket> request,
+ NetworkContext* context)
+ : binding_(this, request.Pass()), context_(context) {
}
WebSocketImpl::~WebSocketImpl() {
diff --git a/mojo/services/network/web_socket_impl.h b/mojo/services/network/web_socket_impl.h
index bb41104..f84f840 100644
--- a/mojo/services/network/web_socket_impl.h
+++ b/mojo/services/network/web_socket_impl.h
@@ -7,7 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "mojo/services/network/public/interfaces/web_socket.mojom.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
namespace net {
class WebSocketChannel;
@@ -19,9 +19,9 @@
// Forms a bridge between the WebSocket mojo interface and the net::WebSocket
// implementation.
-class WebSocketImpl : public InterfaceImpl<WebSocket> {
+class WebSocketImpl : public WebSocket {
public:
- explicit WebSocketImpl(NetworkContext* context);
+ WebSocketImpl(InterfaceRequest<WebSocket> request, NetworkContext* context);
~WebSocketImpl() override;
private:
@@ -41,6 +41,7 @@
uint32_t num_bytes,
const char* data);
+ StrongBinding<WebSocket> binding_;
// The channel we use to send events to the network.
scoped_ptr<net::WebSocketChannel> channel_;
ScopedDataPipeConsumerHandle send_stream_;