Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: mojo/services/network/main.cc

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix message loop destruction order Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/services/network/main.cc
diff --git a/mojo/services/network/main.cc b/mojo/services/network/main.cc
index 718a4310e912811c75ce6f2966e164782e1ab579..d47a7d66bb4cfe51aa3d37011de5baf55cb30b03 100644
--- a/mojo/services/network/main.cc
+++ b/mojo/services/network/main.cc
@@ -11,10 +11,17 @@
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/bindings/interface_factory_with_context.h"
+#include "mojo/public/cpp/bindings/interface_ptr.h"
+#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
#include "mojo/services/network/network_context.h"
#include "mojo/services/network/network_service_impl.h"
class Delegate : public mojo::ApplicationDelegate {
+ typedef mojo::InterfaceFactoryWithContext<mojo::NetworkServiceImpl,
+ mojo::NetworkContext>
+ NetworkFactory;
+
public:
Delegate() {}
@@ -23,17 +30,20 @@ class Delegate : public mojo::ApplicationDelegate {
CHECK(PathService::Get(base::DIR_TEMP, &base_path));
base_path = base_path.Append(FILE_PATH_LITERAL("network_service"));
context_.reset(new mojo::NetworkContext(base_path));
+ network_service_factory_.reset(new NetworkFactory(context_.get()));
}
+ // mojo::ApplicationDelegate implementation.
virtual bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
DCHECK(context_);
- connection->AddService<mojo::NetworkServiceImpl>(context_.get());
+ connection->AddService(network_service_factory_.get());
return true;
}
private:
scoped_ptr<mojo::NetworkContext> context_;
+ scoped_ptr<NetworkFactory> network_service_factory_;
};
extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain(

Powered by Google App Engine
This is Rietveld 408576698