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

Side by Side Diff: chrome/browser/renderer_host/socket_stream_dispatcher_host.cc

Issue 6474012: Create a path to deliver SocketStream errors to the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit test and test_shell code Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/renderer_host/socket_stream_dispatcher_host.h" 5 #include "chrome/browser/renderer_host/socket_stream_dispatcher_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/renderer_host/socket_stream_host.h" 9 #include "chrome/browser/renderer_host/socket_stream_host.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void SocketStreamDispatcherHost::OnClose(net::SocketStream* socket) { 93 void SocketStreamDispatcherHost::OnClose(net::SocketStream* socket) {
94 int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket); 94 int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket);
95 DVLOG(1) << "SocketStreamDispatcherHost::OnClosed socket_id=" << socket_id; 95 DVLOG(1) << "SocketStreamDispatcherHost::OnClosed socket_id=" << socket_id;
96 if (socket_id == chrome_common_net::kNoSocketId) { 96 if (socket_id == chrome_common_net::kNoSocketId) {
97 LOG(ERROR) << "NoSocketId in OnClose"; 97 LOG(ERROR) << "NoSocketId in OnClose";
98 return; 98 return;
99 } 99 }
100 DeleteSocketStreamHost(socket_id); 100 DeleteSocketStreamHost(socket_id);
101 } 101 }
102 102
103 void SocketStreamDispatcherHost::OnError(const net::SocketStream* socket,
104 int error) {
105 int socket_id = SocketStreamHost::SocketIdFromSocketStream(socket);
106 DVLOG(1) << "SocketStreamDispatcherHost::OnError socket_id=" << socket_id;
107 if (socket_id == chrome_common_net::kNoSocketId) {
108 LOG(ERROR) << "NoSocketId in OnError";
109 return;
110 }
111 if (!Send(new ViewMsg_SocketStream_Error(socket_id, error))) {
112 LOG(ERROR) << "ViewMsg_SocketStream_ReceivedData failed.";
113 DeleteSocketStreamHost(socket_id);
114 }
115 }
116
103 // Message handlers called by OnMessageReceived. 117 // Message handlers called by OnMessageReceived.
104 void SocketStreamDispatcherHost::OnConnect(const GURL& url, int socket_id) { 118 void SocketStreamDispatcherHost::OnConnect(const GURL& url, int socket_id) {
105 DVLOG(1) << "SocketStreamDispatcherHost::OnConnect url=" << url 119 DVLOG(1) << "SocketStreamDispatcherHost::OnConnect url=" << url
106 << " socket_id=" << socket_id; 120 << " socket_id=" << socket_id;
107 DCHECK_NE(chrome_common_net::kNoSocketId, socket_id); 121 DCHECK_NE(chrome_common_net::kNoSocketId, socket_id);
108 if (hosts_.Lookup(socket_id)) { 122 if (hosts_.Lookup(socket_id)) {
109 LOG(ERROR) << "socket_id=" << socket_id << " already registered."; 123 LOG(ERROR) << "socket_id=" << socket_id << " already registered.";
110 return; 124 return;
111 } 125 }
112 SocketStreamHost* socket_stream_host = new SocketStreamHost(this, socket_id); 126 SocketStreamHost* socket_stream_host = new SocketStreamHost(this, socket_id);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 169 }
156 if (!rv) { 170 if (!rv) {
157 URLRequestContextGetter* context_getter = 171 URLRequestContextGetter* context_getter =
158 Profile::GetDefaultRequestContext(); 172 Profile::GetDefaultRequestContext();
159 if (context_getter) 173 if (context_getter)
160 rv = context_getter->GetURLRequestContext(); 174 rv = context_getter->GetURLRequestContext();
161 } 175 }
162 176
163 return rv; 177 return rv;
164 } 178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698