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

Side by Side Diff: mojo/shell/app_container.cc

Issue 72123002: Work in progress for end-to-end bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add MessageLoop instance to SampleApp and run it Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/shell/app_container.h" 5 #include "mojo/shell/app_container.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 AppContainer::~AppContainer() { 61 AppContainer::~AppContainer() {
62 } 62 }
63 63
64 void AppContainer::Load(const GURL& app_url) { 64 void AppContainer::Load(const GURL& app_url) {
65 request_ = context_->loader()->Load(app_url, this); 65 request_ = context_->loader()->Load(app_url, this);
66 } 66 }
67 67
68 void AppContainer::DidCompleteLoad(const GURL& app_url, 68 void AppContainer::DidCompleteLoad(const GURL& app_url,
69 const base::FilePath& app_path) { 69 const base::FilePath& app_path) {
70 Handle shell_handle;
70 Handle app_handle; 71 Handle app_handle;
71 MojoResult result = CreateMessagePipe(&shell_handle_, &app_handle); 72 MojoResult result = CreateMessagePipe(&shell_handle, &app_handle);
72 if (result < MOJO_RESULT_OK) { 73 if (result < MOJO_RESULT_OK) {
73 // Failure.. 74 // Failure..
74 } 75 }
75 76
77 hello_world_service_.reset(
78 new examples::HelloWorldServiceImpl(shell_handle));
79
76 // Launch the app on its own thread. 80 // Launch the app on its own thread.
77 // TODO(beng): Create a unique thread name. 81 // TODO(beng): Create a unique thread name.
78 thread_.reset(new base::Thread("app_thread")); 82 thread_.reset(new base::Thread("app_thread"));
79 thread_->Start(); 83 thread_->Start();
80 thread_->message_loop_proxy()->PostTaskAndReply( 84 thread_->message_loop_proxy()->PostTaskAndReply(
81 FROM_HERE, 85 FROM_HERE,
82 base::Bind(&LaunchAppOnThread, app_path, app_handle), 86 base::Bind(&LaunchAppOnThread, app_path, app_handle),
83 base::Bind(&AppContainer::AppCompleted, weak_factory_.GetWeakPtr())); 87 base::Bind(&AppContainer::AppCompleted, weak_factory_.GetWeakPtr()));
84 88
85 const char* hello_msg = "Hello";
86 result = WriteMessage(shell_handle_, hello_msg,
87 static_cast<uint32_t>(strlen(hello_msg)+1),
88 NULL, 0, MOJO_WRITE_MESSAGE_FLAG_NONE);
89 if (result < MOJO_RESULT_OK) {
90 // Failure..
91 }
92
93 // TODO(beng): This should be created on demand by the NativeViewportService 89 // TODO(beng): This should be created on demand by the NativeViewportService
94 // when it is retrieved by the app. 90 // when it is retrieved by the app.
95 native_viewport_controller_.reset( 91 // native_viewport_controller_.reset(
96 new services::NativeViewportController(context_, shell_handle_)); 92 // new services::NativeViewportController(context_, shell_handle_));
97 } 93 }
98 94
99 void AppContainer::AppCompleted() { 95 void AppContainer::AppCompleted() {
100 native_viewport_controller_->Close(); 96 hello_world_service_.reset();
97 // native_viewport_controller_->Close();
darin (slow to review) 2013/11/14 00:05:34 nit: commented out code should have a TODO
DaveMoore 2013/11/14 23:46:54 Done.
101 98
102 thread_.reset(); 99 thread_.reset();
103 Close(shell_handle_);
104 } 100 }
105 101
106 } // namespace shell 102 } // namespace shell
107 } // namespace mojo 103 } // namespace mojo
OLDNEW
« mojo/examples/sample_app/sample_app.cc ('K') | « mojo/shell/app_container.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698