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

Side by Side Diff: content/child/socket_stream_dispatcher.cc

Issue 432553003: Remove redundant mapping of net errors to strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to comments Created 6 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/child/socket_stream_dispatcher.h" 5 #include "content/child/socket_stream_dispatcher.h"
6 6
7 #include <string>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/id_map.h" 11 #include "base/id_map.h"
11 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
14 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "content/child/child_thread.h" 17 #include "content/child/child_thread.h"
(...skipping 22 matching lines...) Expand all
39 // WebSocketStreamHandleBridge methods. 40 // WebSocketStreamHandleBridge methods.
40 virtual void Connect(const GURL& url) OVERRIDE; 41 virtual void Connect(const GURL& url) OVERRIDE;
41 virtual bool Send(const std::vector<char>& data) OVERRIDE; 42 virtual bool Send(const std::vector<char>& data) OVERRIDE;
42 virtual void Close() OVERRIDE; 43 virtual void Close() OVERRIDE;
43 44
44 // Called by SocketStreamDispatcher. 45 // Called by SocketStreamDispatcher.
45 void OnConnected(int max_amount_send_allowed); 46 void OnConnected(int max_amount_send_allowed);
46 void OnSentData(int amount_sent); 47 void OnSentData(int amount_sent);
47 void OnReceivedData(const std::vector<char>& data); 48 void OnReceivedData(const std::vector<char>& data);
48 void OnClosed(); 49 void OnClosed();
49 void OnFailed(int error_code, const char* error_msg); 50 void OnFailed(int error_code, const std::string& error_msg);
50 51
51 private: 52 private:
52 virtual ~IPCWebSocketStreamHandleBridge(); 53 virtual ~IPCWebSocketStreamHandleBridge();
53 54
54 // The ID for this bridge and corresponding SocketStream instance in the 55 // The ID for this bridge and corresponding SocketStream instance in the
55 // browser process. 56 // browser process.
56 int socket_id_; 57 int socket_id_;
57 58
58 blink::WebSocketStreamHandle* handle_; 59 blink::WebSocketStreamHandle* handle_;
59 WebSocketStreamHandleDelegate* delegate_; 60 WebSocketStreamHandleDelegate* delegate_;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 all_bridges.Get().Remove(socket_id_); 157 all_bridges.Get().Remove(socket_id_);
157 socket_id_ = kNoSocketId; 158 socket_id_ = kNoSocketId;
158 } 159 }
159 if (delegate_) 160 if (delegate_)
160 delegate_->DidClose(handle_); 161 delegate_->DidClose(handle_);
161 delegate_ = NULL; 162 delegate_ = NULL;
162 Release(); 163 Release();
163 } 164 }
164 165
165 void IPCWebSocketStreamHandleBridge::OnFailed(int error_code, 166 void IPCWebSocketStreamHandleBridge::OnFailed(int error_code,
166 const char* error_msg) { 167 const std::string& error_msg) {
167 DVLOG(1) << "Bridge #" << socket_id_ << " OnFailed (error_code=" << error_code 168 DVLOG(1) << "Bridge #" << socket_id_ << " OnFailed (error_code=" << error_code
168 << ")"; 169 << ")";
169 if (delegate_) 170 if (delegate_)
170 delegate_->DidFail(handle_, error_code, base::ASCIIToUTF16(error_msg)); 171 delegate_->DidFail(handle_, error_code, base::ASCIIToUTF16(error_msg));
171 } 172 }
172 173
173 SocketStreamDispatcher::SocketStreamDispatcher() { 174 SocketStreamDispatcher::SocketStreamDispatcher() {
174 } 175 }
175 176
176 // static 177 // static
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 void SocketStreamDispatcher::OnFailed(int socket_id, int error_code) { 246 void SocketStreamDispatcher::OnFailed(int socket_id, int error_code) {
246 IPCWebSocketStreamHandleBridge* bridge = 247 IPCWebSocketStreamHandleBridge* bridge =
247 IPCWebSocketStreamHandleBridge::FromSocketId(socket_id); 248 IPCWebSocketStreamHandleBridge::FromSocketId(socket_id);
248 if (bridge) 249 if (bridge)
249 bridge->OnFailed(error_code, net::ErrorToString(error_code)); 250 bridge->OnFailed(error_code, net::ErrorToString(error_code));
250 else 251 else
251 DLOG(ERROR) << "No bridge for socket_id=" << socket_id; 252 DLOG(ERROR) << "No bridge for socket_id=" << socket_id;
252 } 253 }
253 254
254 } // namespace content 255 } // namespace content
OLDNEW
« no previous file with comments | « components/cronet/android/org_chromium_net_UrlRequest.cc ('k') | device/bluetooth/bluetooth_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698