OLD | NEW |
---|---|
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 "chromecast/shell/browser/devtools/remote_debugging_server.h" | 5 #include "chromecast/shell/browser/devtools/remote_debugging_server.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
23 #include "content/public/browser/android/devtools_auth.h" | 23 #include "content/public/browser/android/devtools_auth.h" |
24 #include "net/socket/unix_domain_server_socket_posix.h" | 24 #include "net/socket/unix_domain_server_socket_posix.h" |
25 #endif // defined(OS_ANDROID) | 25 #endif // defined(OS_ANDROID) |
26 | 26 |
27 namespace chromecast { | 27 namespace chromecast { |
28 namespace shell { | 28 namespace shell { |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 #if defined(OS_ANDROID) | |
33 const char kFrontEndURL[] = | |
34 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html"; | |
35 #endif // defined(OS_ANDROID) | |
32 const int kDefaultRemoteDebuggingPort = 9222; | 36 const int kDefaultRemoteDebuggingPort = 9222; |
33 | 37 |
34 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
35 class UnixDomainServerSocketFactory | 39 class UnixDomainServerSocketFactory |
36 : public content::DevToolsHttpHandler::ServerSocketFactory { | 40 : public content::DevToolsHttpHandler::ServerSocketFactory { |
37 public: | 41 public: |
38 explicit UnixDomainServerSocketFactory(const std::string& socket_name) | 42 explicit UnixDomainServerSocketFactory(const std::string& socket_name) |
39 : content::DevToolsHttpHandler::ServerSocketFactory(socket_name, 0, 1) {} | 43 : content::DevToolsHttpHandler::ServerSocketFactory(socket_name, 0, 1) {} |
40 | 44 |
41 private: | 45 private: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 switches::kRemoteDebuggingSocketName); | 82 switches::kRemoteDebuggingSocketName); |
79 } | 83 } |
80 return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>( | 84 return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>( |
81 new UnixDomainServerSocketFactory(socket_name)); | 85 new UnixDomainServerSocketFactory(socket_name)); |
82 #else | 86 #else |
83 return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>( | 87 return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>( |
84 new TCPServerSocketFactory("0.0.0.0", port, 1)); | 88 new TCPServerSocketFactory("0.0.0.0", port, 1)); |
85 #endif | 89 #endif |
86 } | 90 } |
87 | 91 |
92 std::string GetFrontendUrl() { | |
93 #if defined(OS_ANDROID) | |
94 return base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()); | |
95 #else | |
96 return std::string(); | |
97 #endif // defined(OS_ANDROID) | |
98 } | |
99 | |
88 } // namespace | 100 } // namespace |
89 | 101 |
90 RemoteDebuggingServer::RemoteDebuggingServer() | 102 RemoteDebuggingServer::RemoteDebuggingServer() |
91 : devtools_http_handler_(NULL), | 103 : devtools_http_handler_(NULL), |
92 port_(0) { | 104 port_(0) { |
93 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 105 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
94 pref_port_.Init(prefs::kRemoteDebuggingPort, | 106 pref_port_.Init(prefs::kRemoteDebuggingPort, |
95 ChromecastConfig::GetInstance()->pref_service(), | 107 ChromecastConfig::GetInstance()->pref_service(), |
96 base::Bind(&RemoteDebuggingServer::OnPortChanged, | 108 base::Bind(&RemoteDebuggingServer::OnPortChanged, |
97 base::Unretained(this))); | 109 base::Unretained(this))); |
(...skipping 27 matching lines...) Expand all Loading... | |
125 LOG(INFO) << "Stop old devtools: port=" << port_; | 137 LOG(INFO) << "Stop old devtools: port=" << port_; |
126 // Note: Stop destroys devtools_http_handler_. | 138 // Note: Stop destroys devtools_http_handler_. |
127 devtools_http_handler_->Stop(); | 139 devtools_http_handler_->Stop(); |
128 devtools_http_handler_ = NULL; | 140 devtools_http_handler_ = NULL; |
129 } | 141 } |
130 | 142 |
131 port_ = new_port; | 143 port_ = new_port; |
132 if (port_ > 0) { | 144 if (port_ > 0) { |
133 devtools_http_handler_ = content::DevToolsHttpHandler::Start( | 145 devtools_http_handler_ = content::DevToolsHttpHandler::Start( |
134 CreateSocketFactory(port_), | 146 CreateSocketFactory(port_), |
135 std::string(), | 147 GetFrontendUrl(), |
dgozman
2014/09/30 13:14:46
Please, also change CastDevToolsDelegate::BundlesF
gunsch
2014/09/30 15:53:30
Done.
| |
136 new CastDevToolsDelegate(), | 148 new CastDevToolsDelegate(), |
137 base::FilePath()); | 149 base::FilePath()); |
138 LOG(INFO) << "Devtools started: port=" << port_; | 150 LOG(INFO) << "Devtools started: port=" << port_; |
139 } | 151 } |
140 } | 152 } |
141 | 153 |
142 } // namespace shell | 154 } // namespace shell |
143 } // namespace chromecast | 155 } // namespace chromecast |
OLD | NEW |