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

Unified Diff: mojo/dart/embedder/dart_state.h

Issue 1262493002: Enable HTTP loading in Mojo dart content handler (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « mojo/dart/embedder/dart_controller.cc ('k') | mojo/dart/http_load_test/main.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/embedder/dart_state.h
diff --git a/mojo/dart/embedder/dart_state.h b/mojo/dart/embedder/dart_state.h
index faaff68a3b7dcd31ad5a0a0b87c5154bcca4b0f2..6ebd27c869cbf833bec69cdaf1e079ad57b316d1 100644
--- a/mojo/dart/embedder/dart_state.h
+++ b/mojo/dart/embedder/dart_state.h
@@ -11,6 +11,8 @@
#include "base/callback.h"
#include "base/macros.h"
#include "mojo/public/c/system/types.h"
+#include "mojo/public/cpp/system/message_pipe.h"
+#include "mojo/services/network/public/interfaces/network_service.mojom.h"
#include "tonic/dart_library_provider.h"
#include "tonic/dart_state.h"
@@ -59,6 +61,26 @@ class MojoDartState : public tonic::DartState {
DCHECK(library_provider_.get() == library_provider);
}
+ // Takes ownership of |raw_handle|.
+ void BindNetworkService(MojoHandle raw_handle) {
+ if (raw_handle == MOJO_HANDLE_INVALID) {
+ return;
+ }
+ DCHECK(!network_service_.is_bound());
+ MessagePipeHandle handle(raw_handle);
+ ScopedMessagePipeHandle message_pipe(handle);
+ InterfacePtrInfo<mojo::NetworkService> interface_info(message_pipe.Pass(),
+ 0);
+ network_service_.Bind(interface_info.Pass());
+ DCHECK(network_service_.is_bound());
+ }
+
+ mojo::NetworkService* network_service() {
+ // Should only be called after |BindNetworkService|.
+ DCHECK(network_service_.is_bound());
+ return network_service_.get();
+ }
+
tonic::DartLibraryProvider* library_provider() const {
return library_provider_.get();
}
@@ -83,6 +105,7 @@ class MojoDartState : public tonic::DartState {
std::string package_root_;
std::set<MojoHandle> unclosed_handles_;
std::unique_ptr<tonic::DartLibraryProvider> library_provider_;
+ mojo::NetworkServicePtr network_service_;
};
} // namespace dart
« no previous file with comments | « mojo/dart/embedder/dart_controller.cc ('k') | mojo/dart/http_load_test/main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698