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

Side by Side Diff: mojo/services/html_viewer/websockethandle_impl.cc

Issue 668663006: Standardize usage of virtual/override/final in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 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 "mojo/services/html_viewer/websockethandle_impl.h" 5 #include "mojo/services/html_viewer/websockethandle_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 }; 62 };
63 63
64 // This class forms a bridge from the mojo WebSocketClient interface and the 64 // This class forms a bridge from the mojo WebSocketClient interface and the
65 // Blink WebSocketHandleClient interface. 65 // Blink WebSocketHandleClient interface.
66 class WebSocketClientImpl : public InterfaceImpl<WebSocketClient> { 66 class WebSocketClientImpl : public InterfaceImpl<WebSocketClient> {
67 public: 67 public:
68 explicit WebSocketClientImpl(WebSocketHandleImpl* handle, 68 explicit WebSocketClientImpl(WebSocketHandleImpl* handle,
69 blink::WebSocketHandleClient* client) 69 blink::WebSocketHandleClient* client)
70 : handle_(handle), client_(client) {} 70 : handle_(handle), client_(client) {}
71 virtual ~WebSocketClientImpl() {} 71 ~WebSocketClientImpl() override {}
72 72
73 private: 73 private:
74 // WebSocketClient methods: 74 // WebSocketClient methods:
75 virtual void DidConnect(bool fail, 75 void DidConnect(bool fail,
76 const String& selected_subprotocol, 76 const String& selected_subprotocol,
77 const String& extensions, 77 const String& extensions,
78 ScopedDataPipeConsumerHandle receive_stream) 78 ScopedDataPipeConsumerHandle receive_stream) override {
79 override {
80 blink::WebSocketHandleClient* client = client_; 79 blink::WebSocketHandleClient* client = client_;
81 WebSocketHandleImpl* handle = handle_; 80 WebSocketHandleImpl* handle = handle_;
82 receive_stream_ = receive_stream.Pass(); 81 receive_stream_ = receive_stream.Pass();
83 read_queue_.reset(new WebSocketReadQueue(receive_stream_.get())); 82 read_queue_.reset(new WebSocketReadQueue(receive_stream_.get()));
84 if (fail) 83 if (fail)
85 handle->Disconnect(); // deletes |this| 84 handle->Disconnect(); // deletes |this|
86 client->didConnect(handle, 85 client->didConnect(handle,
87 fail, 86 fail,
88 selected_subprotocol.To<WebString>(), 87 selected_subprotocol.To<WebString>(),
89 extensions.To<WebString>()); 88 extensions.To<WebString>());
90 // |handle| can be deleted here. 89 // |handle| can be deleted here.
91 } 90 }
92 91
93 virtual void DidReceiveData(bool fin, 92 void DidReceiveData(bool fin,
94 WebSocket::MessageType type, 93 WebSocket::MessageType type,
95 uint32_t num_bytes) override { 94 uint32_t num_bytes) override {
96 read_queue_->Read(num_bytes, 95 read_queue_->Read(num_bytes,
97 base::Bind(&WebSocketClientImpl::DidReadFromReceiveStream, 96 base::Bind(&WebSocketClientImpl::DidReadFromReceiveStream,
98 base::Unretained(this), 97 base::Unretained(this),
99 fin, type, num_bytes)); 98 fin, type, num_bytes));
100 } 99 }
101 100
102 virtual void DidReceiveFlowControl(int64_t quota) override { 101 void DidReceiveFlowControl(int64_t quota) override {
103 client_->didReceiveFlowControl(handle_, quota); 102 client_->didReceiveFlowControl(handle_, quota);
104 // |handle| can be deleted here. 103 // |handle| can be deleted here.
105 } 104 }
106 105
107 virtual void DidFail(const String& message) override { 106 void DidFail(const String& message) override {
108 blink::WebSocketHandleClient* client = client_; 107 blink::WebSocketHandleClient* client = client_;
109 WebSocketHandleImpl* handle = handle_; 108 WebSocketHandleImpl* handle = handle_;
110 handle->Disconnect(); // deletes |this| 109 handle->Disconnect(); // deletes |this|
111 client->didFail(handle, message.To<WebString>()); 110 client->didFail(handle, message.To<WebString>());
112 // |handle| can be deleted here. 111 // |handle| can be deleted here.
113 } 112 }
114 113
115 virtual void DidClose(bool was_clean, 114 void DidClose(bool was_clean, uint16_t code, const String& reason) override {
116 uint16_t code,
117 const String& reason) override {
118 blink::WebSocketHandleClient* client = client_; 115 blink::WebSocketHandleClient* client = client_;
119 WebSocketHandleImpl* handle = handle_; 116 WebSocketHandleImpl* handle = handle_;
120 handle->Disconnect(); // deletes |this| 117 handle->Disconnect(); // deletes |this|
121 client->didClose(handle, was_clean, code, reason.To<WebString>()); 118 client->didClose(handle, was_clean, code, reason.To<WebString>());
122 // |handle| can be deleted here. 119 // |handle| can be deleted here.
123 } 120 }
124 121
125 void DidReadFromReceiveStream(bool fin, 122 void DidReadFromReceiveStream(bool fin,
126 WebSocket::MessageType type, 123 WebSocket::MessageType type,
127 uint32_t num_bytes, 124 uint32_t num_bytes,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 const char* data) { 206 const char* data) {
210 web_socket_->Send(fin, ConvertTo<WebSocket::MessageType>(type), num_bytes); 207 web_socket_->Send(fin, ConvertTo<WebSocket::MessageType>(type), num_bytes);
211 } 208 }
212 209
213 void WebSocketHandleImpl::Disconnect() { 210 void WebSocketHandleImpl::Disconnect() {
214 did_close_ = true; 211 did_close_ = true;
215 client_.reset(); 212 client_.reset();
216 } 213 }
217 214
218 } // namespace mojo 215 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/html_viewer/weblayertreeview_impl.h ('k') | mojo/services/html_viewer/webthread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698