forked from sanyaade-mobiledev/chromium.src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mojo] Almost connect mojo_js with hello_world_service
This CL connects mojo_js with hello_world_service. After this CL, the JavaScript and C++ implementations have reached parity. BUG=317398 Review URL: https://codereview.chromium.org/82953004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237018 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
abarth@chromium.org
committed
Nov 25, 2013
1 parent
6a36eff
commit 0d72f00
Showing
24 changed files
with
642 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
include_rules = [ | ||
"+gin", | ||
"+v8", | ||
"-base", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "mojo/apps/js/bootstrap.h" | ||
|
||
#include "base/message_loop/message_loop.h" | ||
#include "gin/per_isolate_data.h" | ||
#include "mojo/public/bindings/js/handle.h" | ||
|
||
namespace mojo { | ||
namespace apps { | ||
|
||
namespace { | ||
|
||
void Quit(const v8::FunctionCallbackInfo<v8::Value>& info) { | ||
base::MessageLoop::current()->QuitNow(); | ||
} | ||
|
||
MojoHandle g_initial_handle = MOJO_HANDLE_INVALID; | ||
|
||
gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; | ||
|
||
} // namespace | ||
|
||
const char Bootstrap::kModuleName[] = "mojo/apps/js/bootstrap"; | ||
|
||
v8::Local<v8::ObjectTemplate> Bootstrap::GetTemplate(v8::Isolate* isolate) { | ||
gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); | ||
v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate( | ||
&g_wrapper_info); | ||
|
||
if (templ.IsEmpty()) { | ||
templ = v8::ObjectTemplate::New(); | ||
templ->Set(gin::StringToSymbol(isolate, "quit"), | ||
v8::FunctionTemplate::New(Quit)); | ||
|
||
// Don't forget to call SetInitialHandle before getting the template. | ||
DCHECK(g_initial_handle != MOJO_HANDLE_INVALID); | ||
templ->Set(gin::StringToSymbol(isolate, "initialHandle"), | ||
gin::ConvertToV8(isolate, g_initial_handle)); | ||
|
||
data->SetObjectTemplate(&g_wrapper_info, templ); | ||
} | ||
|
||
return templ; | ||
} | ||
|
||
void Bootstrap::SetInitialHandle(MojoHandle pipe) { | ||
g_initial_handle = pipe; | ||
} | ||
|
||
} // namespace apps | ||
} // namespace mojo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef MOJO_APPS_JS_BOOTSTRAP_H_ | ||
#define MOJO_APPS_JS_BOOTSTRAP_H_ | ||
|
||
#include "mojo/public/system/core.h" | ||
#include "v8/include/v8.h" | ||
|
||
namespace mojo { | ||
namespace apps { | ||
|
||
class Bootstrap { | ||
public: | ||
static const char kModuleName[]; | ||
static v8::Local<v8::ObjectTemplate> GetTemplate(v8::Isolate* isolate); | ||
|
||
// Must be called before the first call to GetTemplate. | ||
static void SetInitialHandle(MojoHandle handle); | ||
}; | ||
|
||
} // namespace apps | ||
} // namespace mojo | ||
|
||
#endif // MOJO_APPS_JS_BOOTSTRAP_H_ |
Oops, something went wrong.