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

Side by Side Diff: sky/tools/debugger/prompt/prompt.cc

Issue 690433004: Add inspect command to skydb (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/weak_ptr.h" 6 #include "base/memory/weak_ptr.h"
7 #include "mojo/application/application_runner_chromium.h" 7 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/public/c/system/main.h" 8 #include "mojo/public/c/system/main.h"
9 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 return true; 66 return true;
67 } 67 }
68 if (command == "trace") { 68 if (command == "trace") {
69 ToggleTracing(); 69 ToggleTracing();
70 return true; 70 return true;
71 } 71 }
72 if (command == "reload") { 72 if (command == "reload") {
73 Reload(); 73 Reload();
74 return true; 74 return true;
75 } 75 }
76 if (command == "inspect") {
77 Inspect();
78 return true;
79 }
76 if (command.size() == 1) { 80 if (command.size() == 1) {
77 char c = command[0]; 81 char c = command[0];
78 if (c == 'h') 82 if (c == 'h')
79 PrintHelp(); 83 PrintHelp();
80 else if (c == 'q') 84 else if (c == 'q')
81 Quit(); 85 Quit();
82 else if (c == 'r') 86 else if (c == 'r')
83 Reload(); 87 Reload();
84 else 88 else
85 std::cout << "Unknown command: " << c << std::endl; 89 std::cout << "Unknown command: " << c << std::endl;
(...skipping 18 matching lines...) Expand all
104 void ScheduleWaitForInput() { 108 void ScheduleWaitForInput() {
105 base::MessageLoop::current()->PostTask(FROM_HERE, 109 base::MessageLoop::current()->PostTask(FROM_HERE,
106 base::Bind(&Prompt::WaitForInput, weak_ptr_factory_.GetWeakPtr())); 110 base::Bind(&Prompt::WaitForInput, weak_ptr_factory_.GetWeakPtr()));
107 } 111 }
108 112
109 void PrintHelp() { 113 void PrintHelp() {
110 std::cout 114 std::cout
111 << "Sky Debugger" << std::endl 115 << "Sky Debugger" << std::endl
112 << "============" << std::endl 116 << "============" << std::endl
113 << "Type a URL to load in the debugger, enter to reload." << std::endl 117 << "Type a URL to load in the debugger, enter to reload." << std::endl
114 << "Commands: help -- Help" << std::endl 118 << "Commands: help -- Help" << std::endl
115 << " trace -- Capture a trace" << std::endl 119 << " trace -- Capture a trace" << std::endl
116 << " reload -- Reload the current page" << std::endl 120 << " reload -- Reload the current page" << std::endl
117 << " q -- Quit" << std::endl; 121 << " inspect -- Inspect the current page" << std::endl
122 << " q -- Quit" << std::endl;
118 } 123 }
119 124
120 void Reload() { 125 void Reload() {
121 debugger_->NavigateToURL(url_); 126 debugger_->NavigateToURL(url_);
122 } 127 }
123 128
129 void Inspect() {
130 debugger_->InjectInspector();
131 std::cout
132 << "Open the following URL in Chrome:" << std::endl
133 << "chrome-devtools://devtools/bundled/devtools.html?ws=localhost:9898"
134 << std::endl;
135 }
136
124 void Quit() { 137 void Quit() {
125 std::cout << "quitting" << std::endl; 138 std::cout << "quitting" << std::endl;
126 exit(0); 139 exit(0);
127 } 140 }
128 141
129 void ToggleTracing() { 142 void ToggleTracing() {
130 if (is_tracing_) { 143 if (is_tracing_) {
131 std::cout << "Stopping trace (writing to sky_viewer.trace)" << std::endl; 144 std::cout << "Stopping trace (writing to sky_viewer.trace)" << std::endl;
132 tracing_->Stop(); 145 tracing_->Stop();
133 } else { 146 } else {
(...skipping 12 matching lines...) Expand all
146 DISALLOW_COPY_AND_ASSIGN(Prompt); 159 DISALLOW_COPY_AND_ASSIGN(Prompt);
147 }; 160 };
148 161
149 } // namespace debugger 162 } // namespace debugger
150 } // namespace sky 163 } // namespace sky
151 164
152 MojoResult MojoMain(MojoHandle shell_handle) { 165 MojoResult MojoMain(MojoHandle shell_handle) {
153 mojo::ApplicationRunnerChromium runner(new sky::debugger::Prompt); 166 mojo::ApplicationRunnerChromium runner(new sky::debugger::Prompt);
154 return runner.Run(shell_handle); 167 return runner.Run(shell_handle);
155 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698