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

Side by Side Diff: services/debugger/debugger.cc

Issue 1157253007: Connect mojo:debugger to window_manager only when requested. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | sky/tools/skydb » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/profiler.h" 8 #include "base/debug/profiler.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 21 matching lines...) Expand all
32 class Debugger : public mojo::ApplicationDelegate, 32 class Debugger : public mojo::ApplicationDelegate,
33 public http_server::HttpHandler { 33 public http_server::HttpHandler {
34 public: 34 public:
35 Debugger() : is_tracing_(false), app_(nullptr), handler_binding_(this) {} 35 Debugger() : is_tracing_(false), app_(nullptr), handler_binding_(this) {}
36 ~Debugger() override {} 36 ~Debugger() override {}
37 37
38 private: 38 private:
39 // mojo::ApplicationDelegate: 39 // mojo::ApplicationDelegate:
40 void Initialize(mojo::ApplicationImpl* app) override { 40 void Initialize(mojo::ApplicationImpl* app) override {
41 app_ = app; 41 app_ = app;
42 app->ConnectToService("mojo:window_manager", &window_manager_);
43 42
44 // Format: --args-for="app_url command_port" 43 // Format: --args-for="app_url command_port"
45 if (app->args().size() < 2) { 44 if (app->args().size() < 2) {
46 LOG(ERROR) << "--args-for required to specify command_port"; 45 LOG(ERROR) << "--args-for required to specify command_port";
47 mojo::ApplicationImpl::Terminate(); 46 mojo::ApplicationImpl::Terminate();
48 return; 47 return;
49 } 48 }
49 if (app->args().size() == 3 && app->args()[2] == "--wm") {
50 // Connect to window manager only if requested, as the user might want to
51 // run the debugger without spawning one.
52 app_->ConnectToService("mojo:window_manager", &window_manager_);
53 }
50 base::StringToUint(app->args()[1], &command_port_); 54 base::StringToUint(app->args()[1], &command_port_);
51 http_server::HttpServerFactoryPtr http_server_factory; 55 http_server::HttpServerFactoryPtr http_server_factory;
52 app->ConnectToService("mojo:http_server", &http_server_factory); 56 app->ConnectToService("mojo:http_server", &http_server_factory);
53 57
54 mojo::NetAddressPtr local_address(mojo::NetAddress::New()); 58 mojo::NetAddressPtr local_address(mojo::NetAddress::New());
55 local_address->family = mojo::NET_ADDRESS_FAMILY_IPV4; 59 local_address->family = mojo::NET_ADDRESS_FAMILY_IPV4;
56 local_address->ipv4 = mojo::NetAddressIPv4::New(); 60 local_address->ipv4 = mojo::NetAddressIPv4::New();
57 local_address->ipv4->addr.resize(4); 61 local_address->ipv4->addr.resize(4);
58 local_address->ipv4->addr[0] = 127; 62 local_address->ipv4->addr[0] = 127;
59 local_address->ipv4->addr[1] = 0; 63 local_address->ipv4->addr[1] = 0;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 126 }
123 127
124 void Load(const HandleRequestCallback& callback, std::string url) { 128 void Load(const HandleRequestCallback& callback, std::string url) {
125 url_ = url; 129 url_ = url;
126 Reload(); 130 Reload();
127 std::string response = std::string("Loaded ") + url + "\n"; 131 std::string response = std::string("Loaded ") + url + "\n";
128 Respond(callback, response); 132 Respond(callback, response);
129 } 133 }
130 134
131 void Reload() { 135 void Reload() {
136 if (!window_manager_)
137 return;
138
132 // SimpleWindowManager will wire up necessary services on our behalf. 139 // SimpleWindowManager will wire up necessary services on our behalf.
133 window_manager_->Embed(url_, nullptr, nullptr); 140 window_manager_->Embed(url_, nullptr, nullptr);
134 } 141 }
135 142
136 void Exit() { 143 void Exit() {
137 // TODO(eseidel): We should orderly shutdown once mojo can. 144 // TODO(eseidel): We should orderly shutdown once mojo can.
138 exit(0); 145 exit(0);
139 } 146 }
140 147
141 void StartTracing(const HandleRequestCallback& callback) { 148 void StartTracing(const HandleRequestCallback& callback) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 DISALLOW_COPY_AND_ASSIGN(Debugger); 212 DISALLOW_COPY_AND_ASSIGN(Debugger);
206 }; 213 };
207 214
208 } // namespace debugger 215 } // namespace debugger
209 216
210 MojoResult MojoMain(MojoHandle application_request) { 217 MojoResult MojoMain(MojoHandle application_request) {
211 mojo::ApplicationRunnerChromium runner(new debugger::Debugger); 218 mojo::ApplicationRunnerChromium runner(new debugger::Debugger);
212 runner.set_message_loop_type(base::MessageLoop::TYPE_IO); 219 runner.set_message_loop_type(base::MessageLoop::TYPE_IO);
213 return runner.Run(application_request); 220 return runner.Run(application_request);
214 } 221 }
OLDNEW
« no previous file with comments | « no previous file | sky/tools/skydb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698