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

Side by Side Diff: chrome/browser/debugger/devtools_protocol_handler.cc

Issue 2868036: Brushed up listen socket: (Closed)
Patch Set: Lint. Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/debugger/devtools_protocol_handler.h" 5 #include "chrome/browser/debugger/devtools_protocol_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/chrome_thread.h" 8 #include "chrome/browser/chrome_thread.h"
9 #include "chrome/browser/debugger/inspectable_tab_proxy.h" 9 #include "chrome/browser/debugger/inspectable_tab_proxy.h"
10 #include "chrome/browser/debugger/devtools_remote_message.h" 10 #include "chrome/browser/debugger/devtools_remote_message.h"
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 void DevToolsProtocolHandler::Start() { 27 void DevToolsProtocolHandler::Start() {
28 ChromeThread::PostTask( 28 ChromeThread::PostTask(
29 ChromeThread::IO, FROM_HERE, 29 ChromeThread::IO, FROM_HERE,
30 NewRunnableMethod(this, &DevToolsProtocolHandler::Init)); 30 NewRunnableMethod(this, &DevToolsProtocolHandler::Init));
31 } 31 }
32 32
33 void DevToolsProtocolHandler::Init() { 33 void DevToolsProtocolHandler::Init() {
34 server_ = DevToolsRemoteListenSocket::Listen( 34 server_ = DevToolsRemoteListenSocket::Listen(
35 "127.0.0.1", port_, this, this); 35 "127.0.0.1", port_, this);
36 } 36 }
37 37
38 void DevToolsProtocolHandler::Stop() { 38 void DevToolsProtocolHandler::Stop() {
39 ChromeThread::PostTask( 39 ChromeThread::PostTask(
40 ChromeThread::IO, FROM_HERE, 40 ChromeThread::IO, FROM_HERE,
41 NewRunnableMethod(this, &DevToolsProtocolHandler::Teardown)); 41 NewRunnableMethod(this, &DevToolsProtocolHandler::Teardown));
42 tool_to_listener_map_.clear(); // Releases all scoped_refptr's to listeners 42 tool_to_listener_map_.clear(); // Releases all scoped_refptr's to listeners
43 } 43 }
44 44
45 // Run in I/O thread 45 // Run in I/O thread
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 NewRunnableMethod( 78 NewRunnableMethod(
79 it->second.get(), &DevToolsRemoteListener::HandleMessage, message)); 79 it->second.get(), &DevToolsRemoteListener::HandleMessage, message));
80 } 80 }
81 81
82 void DevToolsProtocolHandler::Send(const DevToolsRemoteMessage& message) { 82 void DevToolsProtocolHandler::Send(const DevToolsRemoteMessage& message) {
83 if (connection_ != NULL) { 83 if (connection_ != NULL) {
84 connection_->Send(message.ToString()); 84 connection_->Send(message.ToString());
85 } 85 }
86 } 86 }
87 87
88 void DevToolsProtocolHandler::DidAccept(ListenSocket *server, 88 void DevToolsProtocolHandler::OnAcceptConnection(ListenSocket *connection) {
89 ListenSocket *connection) {
90 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 89 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
91 if (connection_ == NULL) { 90 connection_ = connection;
92 connection_ = connection;
93 connection_->AddRef();
94 }
95 // else the connection will get deleted itself with scoped_refptr
96 } 91 }
97 92
98 void DevToolsProtocolHandler::DidRead(ListenSocket *connection, 93 void DevToolsProtocolHandler::OnConnectionLost() {
99 const std::string& data) {
100 // Not used.
101 }
102
103 void DevToolsProtocolHandler::DidClose(ListenSocket *sock) {
104 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); 94 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
105 DCHECK(connection_ == sock);
106 connection_ = NULL; 95 connection_ = NULL;
107 sock->Release();
108 for (ToolToListenerMap::const_iterator it = tool_to_listener_map_.begin(), 96 for (ToolToListenerMap::const_iterator it = tool_to_listener_map_.begin(),
109 end = tool_to_listener_map_.end(); 97 end = tool_to_listener_map_.end();
110 it != end; 98 it != end;
111 ++it) { 99 ++it) {
112 ChromeThread::PostTask( 100 ChromeThread::PostTask(
113 ChromeThread::UI, FROM_HERE, 101 ChromeThread::UI, FROM_HERE,
114 NewRunnableMethod( 102 NewRunnableMethod(
115 it->second.get(), &DevToolsRemoteListener::OnConnectionLost)); 103 it->second.get(), &DevToolsRemoteListener::OnConnectionLost));
116 } 104 }
117 } 105 }
OLDNEW
« no previous file with comments | « chrome/browser/debugger/devtools_protocol_handler.h ('k') | chrome/browser/debugger/devtools_remote.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698