Skip to content

Commit

Permalink
support source protection with snapshot
Browse files Browse the repository at this point in the history
Fix #269
  • Loading branch information
rogerwang committed Feb 10, 2013
1 parent 464310f commit 549e3a8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/common/shell_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const char kWorkingDirectory[] = "working-directory";
// Pass the main script to node.
const char kNodeMain[] = "node-main";

// snapshot file path
const char kSnapshot[] = "snapshot";

const char kmMain[] = "main";
const char kmName[] = "name";
const char kmWebkit[] = "webkit";
Expand Down
1 change: 1 addition & 0 deletions src/common/shell_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern const char kNoToolbar[];
extern const char kUrl[];
extern const char kWorkingDirectory[];
extern const char kNodeMain[];
extern const char kSnapshot[];

// Manifest settings
extern const char kmMain[];
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/shell_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,15 @@ void ShellContentRendererClient::RenderThreadStarted() {
// Initialize uv.
node::SetupUv(argc, argv);

std::string snapshot_path;
if (command_line->HasSwitch(switches::kSnapshot)) {
snapshot_path = command_line->GetSwitchValuePath(switches::kSnapshot).AsUTF8Unsafe();
}
// Initialize node after render thread is started.
v8::V8::Initialize();
if (!snapshot_path.empty()) {
v8::V8::Initialize(snapshot_path.c_str());
}else
v8::V8::Initialize();
v8::HandleScope scope;

// Install window bindings into node. The Window API is implemented in node's
Expand Down
4 changes: 4 additions & 0 deletions src/shell_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
std::string node_main;
if (package->root()->GetString(switches::kNodeMain, &node_main))
command_line->AppendSwitchASCII(switches::kNodeMain, node_main);

std::string snapshot_path;
if (package->root()->GetString(switches::kSnapshot, &snapshot_path))
command_line->AppendSwitchASCII(switches::kSnapshot, snapshot_path);
}
}

Expand Down

0 comments on commit 549e3a8

Please sign in to comment.