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

Side by Side Diff: net/websockets/websocket_job_test.cc

Issue 623213004: replace OVERRIDE and FINAL with override and final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo unwanted change in comment 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
« no previous file with comments | « net/websockets/websocket_job.h ('k') | net/websockets/websocket_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "net/websockets/websocket_job.h" 5 #include "net/websockets/websocket_job.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 27 matching lines...) Expand all
38 namespace net { 38 namespace net {
39 39
40 namespace { 40 namespace {
41 41
42 class MockSocketStream : public SocketStream { 42 class MockSocketStream : public SocketStream {
43 public: 43 public:
44 MockSocketStream(const GURL& url, SocketStream::Delegate* delegate, 44 MockSocketStream(const GURL& url, SocketStream::Delegate* delegate,
45 URLRequestContext* context, CookieStore* cookie_store) 45 URLRequestContext* context, CookieStore* cookie_store)
46 : SocketStream(url, delegate, context, cookie_store) {} 46 : SocketStream(url, delegate, context, cookie_store) {}
47 47
48 virtual void Connect() OVERRIDE {} 48 virtual void Connect() override {}
49 virtual bool SendData(const char* data, int len) OVERRIDE { 49 virtual bool SendData(const char* data, int len) override {
50 sent_data_ += std::string(data, len); 50 sent_data_ += std::string(data, len);
51 return true; 51 return true;
52 } 52 }
53 53
54 virtual void Close() OVERRIDE {} 54 virtual void Close() override {}
55 virtual void RestartWithAuth( 55 virtual void RestartWithAuth(
56 const AuthCredentials& credentials) OVERRIDE { 56 const AuthCredentials& credentials) override {
57 } 57 }
58 58
59 virtual void DetachDelegate() OVERRIDE { 59 virtual void DetachDelegate() override {
60 delegate_ = NULL; 60 delegate_ = NULL;
61 } 61 }
62 62
63 const std::string& sent_data() const { 63 const std::string& sent_data() const {
64 return sent_data_; 64 return sent_data_;
65 } 65 }
66 66
67 protected: 67 protected:
68 virtual ~MockSocketStream() {} 68 virtual ~MockSocketStream() {}
69 69
(...skipping 21 matching lines...) Expand all
91 } 91 }
92 void SetOnReceivedData(const base::Closure& callback) { 92 void SetOnReceivedData(const base::Closure& callback) {
93 on_received_data_ = callback; 93 on_received_data_ = callback;
94 } 94 }
95 void SetOnClose(const base::Closure& callback) { 95 void SetOnClose(const base::Closure& callback) {
96 on_close_ = callback; 96 on_close_ = callback;
97 } 97 }
98 98
99 virtual int OnStartOpenConnection( 99 virtual int OnStartOpenConnection(
100 SocketStream* socket, 100 SocketStream* socket,
101 const CompletionCallback& callback) OVERRIDE { 101 const CompletionCallback& callback) override {
102 if (!on_start_open_connection_.is_null()) 102 if (!on_start_open_connection_.is_null())
103 on_start_open_connection_.Run(); 103 on_start_open_connection_.Run();
104 return OK; 104 return OK;
105 } 105 }
106 virtual void OnConnected(SocketStream* socket, 106 virtual void OnConnected(SocketStream* socket,
107 int max_pending_send_allowed) OVERRIDE { 107 int max_pending_send_allowed) override {
108 if (!on_connected_.is_null()) 108 if (!on_connected_.is_null())
109 on_connected_.Run(); 109 on_connected_.Run();
110 } 110 }
111 virtual void OnSentData(SocketStream* socket, 111 virtual void OnSentData(SocketStream* socket,
112 int amount_sent) OVERRIDE { 112 int amount_sent) override {
113 amount_sent_ += amount_sent; 113 amount_sent_ += amount_sent;
114 if (!on_sent_data_.is_null()) 114 if (!on_sent_data_.is_null())
115 on_sent_data_.Run(); 115 on_sent_data_.Run();
116 } 116 }
117 virtual void OnReceivedData(SocketStream* socket, 117 virtual void OnReceivedData(SocketStream* socket,
118 const char* data, int len) OVERRIDE { 118 const char* data, int len) override {
119 received_data_ += std::string(data, len); 119 received_data_ += std::string(data, len);
120 if (!on_received_data_.is_null()) 120 if (!on_received_data_.is_null())
121 on_received_data_.Run(); 121 on_received_data_.Run();
122 } 122 }
123 virtual void OnClose(SocketStream* socket) OVERRIDE { 123 virtual void OnClose(SocketStream* socket) override {
124 if (!on_close_.is_null()) 124 if (!on_close_.is_null())
125 on_close_.Run(); 125 on_close_.Run();
126 } 126 }
127 virtual bool CanGetCookies(SocketStream* socket, 127 virtual bool CanGetCookies(SocketStream* socket,
128 const GURL& url) OVERRIDE { 128 const GURL& url) override {
129 return allow_all_cookies_; 129 return allow_all_cookies_;
130 } 130 }
131 virtual bool CanSetCookie(SocketStream* request, 131 virtual bool CanSetCookie(SocketStream* request,
132 const GURL& url, 132 const GURL& url,
133 const std::string& cookie_line, 133 const std::string& cookie_line,
134 CookieOptions* options) OVERRIDE { 134 CookieOptions* options) override {
135 return allow_all_cookies_; 135 return allow_all_cookies_;
136 } 136 }
137 137
138 size_t amount_sent() const { return amount_sent_; } 138 size_t amount_sent() const { return amount_sent_; }
139 const std::string& received_data() const { return received_data_; } 139 const std::string& received_data() const { return received_data_; }
140 140
141 private: 141 private:
142 int amount_sent_; 142 int amount_sent_;
143 bool allow_all_cookies_; 143 bool allow_all_cookies_;
144 std::string received_data_; 144 std::string received_data_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 } 184 }
185 return result; 185 return result;
186 } 186 }
187 187
188 // CookieStore: 188 // CookieStore:
189 virtual void SetCookieWithOptionsAsync( 189 virtual void SetCookieWithOptionsAsync(
190 const GURL& url, 190 const GURL& url,
191 const std::string& cookie_line, 191 const std::string& cookie_line,
192 const CookieOptions& options, 192 const CookieOptions& options,
193 const SetCookiesCallback& callback) OVERRIDE { 193 const SetCookiesCallback& callback) override {
194 bool result = SetCookieWithOptions(url, cookie_line, options); 194 bool result = SetCookieWithOptions(url, cookie_line, options);
195 if (!callback.is_null()) 195 if (!callback.is_null())
196 callback.Run(result); 196 callback.Run(result);
197 } 197 }
198 198
199 virtual void GetCookiesWithOptionsAsync( 199 virtual void GetCookiesWithOptionsAsync(
200 const GURL& url, 200 const GURL& url,
201 const CookieOptions& options, 201 const CookieOptions& options,
202 const GetCookiesCallback& callback) OVERRIDE { 202 const GetCookiesCallback& callback) override {
203 if (!callback.is_null()) 203 if (!callback.is_null())
204 callback.Run(GetCookiesWithOptions(url, options)); 204 callback.Run(GetCookiesWithOptions(url, options));
205 } 205 }
206 206
207 virtual void GetAllCookiesForURLAsync( 207 virtual void GetAllCookiesForURLAsync(
208 const GURL& url, 208 const GURL& url,
209 const GetCookieListCallback& callback) OVERRIDE { 209 const GetCookieListCallback& callback) override {
210 ADD_FAILURE(); 210 ADD_FAILURE();
211 } 211 }
212 212
213 virtual void DeleteCookieAsync(const GURL& url, 213 virtual void DeleteCookieAsync(const GURL& url,
214 const std::string& cookie_name, 214 const std::string& cookie_name,
215 const base::Closure& callback) OVERRIDE { 215 const base::Closure& callback) override {
216 ADD_FAILURE(); 216 ADD_FAILURE();
217 } 217 }
218 218
219 virtual void DeleteAllCreatedBetweenAsync( 219 virtual void DeleteAllCreatedBetweenAsync(
220 const base::Time& delete_begin, 220 const base::Time& delete_begin,
221 const base::Time& delete_end, 221 const base::Time& delete_end,
222 const DeleteCallback& callback) OVERRIDE { 222 const DeleteCallback& callback) override {
223 ADD_FAILURE(); 223 ADD_FAILURE();
224 } 224 }
225 225
226 virtual void DeleteAllCreatedBetweenForHostAsync( 226 virtual void DeleteAllCreatedBetweenForHostAsync(
227 const base::Time delete_begin, 227 const base::Time delete_begin,
228 const base::Time delete_end, 228 const base::Time delete_end,
229 const GURL& url, 229 const GURL& url,
230 const DeleteCallback& callback) OVERRIDE { 230 const DeleteCallback& callback) override {
231 ADD_FAILURE(); 231 ADD_FAILURE();
232 } 232 }
233 233
234 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) OVERRIDE { 234 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) override {
235 ADD_FAILURE(); 235 ADD_FAILURE();
236 } 236 }
237 237
238 virtual CookieMonster* GetCookieMonster() OVERRIDE { return NULL; } 238 virtual CookieMonster* GetCookieMonster() override { return NULL; }
239 239
240 const std::vector<Entry>& entries() const { return entries_; } 240 const std::vector<Entry>& entries() const { return entries_; }
241 241
242 private: 242 private:
243 friend class base::RefCountedThreadSafe<MockCookieStore>; 243 friend class base::RefCountedThreadSafe<MockCookieStore>;
244 virtual ~MockCookieStore() {} 244 virtual ~MockCookieStore() {}
245 245
246 std::vector<Entry> entries_; 246 std::vector<Entry> entries_;
247 }; 247 };
248 248
249 class MockSSLConfigService : public SSLConfigService { 249 class MockSSLConfigService : public SSLConfigService {
250 public: 250 public:
251 virtual void GetSSLConfig(SSLConfig* config) OVERRIDE {} 251 virtual void GetSSLConfig(SSLConfig* config) override {}
252 252
253 protected: 253 protected:
254 virtual ~MockSSLConfigService() {} 254 virtual ~MockSSLConfigService() {}
255 }; 255 };
256 256
257 class MockURLRequestContext : public URLRequestContext { 257 class MockURLRequestContext : public URLRequestContext {
258 public: 258 public:
259 explicit MockURLRequestContext(CookieStore* cookie_store) 259 explicit MockURLRequestContext(CookieStore* cookie_store)
260 : transport_security_state_() { 260 : transport_security_state_() {
261 set_cookie_store(cookie_store); 261 set_cookie_store(cookie_store);
(...skipping 29 matching lines...) Expand all
291 host_port_pair_.set_port(80); 291 host_port_pair_.set_port(80);
292 spdy_session_key_ = SpdySessionKey(host_port_pair_, 292 spdy_session_key_ = SpdySessionKey(host_port_pair_,
293 ProxyServer::Direct(), 293 ProxyServer::Direct(),
294 PRIVACY_MODE_DISABLED); 294 PRIVACY_MODE_DISABLED);
295 session_ = CreateInsecureSpdySession( 295 session_ = CreateInsecureSpdySession(
296 http_session_, spdy_session_key_, BoundNetLog()); 296 http_session_, spdy_session_key_, BoundNetLog());
297 } 297 }
298 298
299 virtual int CreateTransaction( 299 virtual int CreateTransaction(
300 RequestPriority priority, 300 RequestPriority priority,
301 scoped_ptr<HttpTransaction>* trans) OVERRIDE { 301 scoped_ptr<HttpTransaction>* trans) override {
302 NOTREACHED(); 302 NOTREACHED();
303 return ERR_UNEXPECTED; 303 return ERR_UNEXPECTED;
304 } 304 }
305 305
306 virtual HttpCache* GetCache() OVERRIDE { 306 virtual HttpCache* GetCache() override {
307 NOTREACHED(); 307 NOTREACHED();
308 return NULL; 308 return NULL;
309 } 309 }
310 310
311 virtual HttpNetworkSession* GetSession() OVERRIDE { 311 virtual HttpNetworkSession* GetSession() override {
312 return http_session_.get(); 312 return http_session_.get();
313 } 313 }
314 314
315 private: 315 private:
316 OrderedSocketData* data_; 316 OrderedSocketData* data_;
317 scoped_ptr<SpdySessionDependencies> session_deps_; 317 scoped_ptr<SpdySessionDependencies> session_deps_;
318 scoped_refptr<HttpNetworkSession> http_session_; 318 scoped_refptr<HttpNetworkSession> http_session_;
319 base::WeakPtr<SpdySession> session_; 319 base::WeakPtr<SpdySession> session_;
320 HostPortPair host_port_pair_; 320 HostPortPair host_port_pair_;
321 SpdySessionKey spdy_session_key_; 321 SpdySessionKey spdy_session_key_;
(...skipping 21 matching lines...) Expand all
343 job_->DetachDelegate(); 343 job_->DetachDelegate();
344 job_ = NULL; 344 job_ = NULL;
345 } 345 }
346 } 346 }
347 347
348 // SocketStream::Delegate implementation 348 // SocketStream::Delegate implementation
349 349
350 // OnStartOpenConnection() is not implemented by SocketStreamDispatcherHost 350 // OnStartOpenConnection() is not implemented by SocketStreamDispatcherHost
351 351
352 virtual void OnConnected(SocketStream* socket, 352 virtual void OnConnected(SocketStream* socket,
353 int max_pending_send_allowed) OVERRIDE { 353 int max_pending_send_allowed) override {
354 DeleteJobMaybe(); 354 DeleteJobMaybe();
355 } 355 }
356 356
357 virtual void OnSentData(SocketStream* socket, int amount_sent) OVERRIDE { 357 virtual void OnSentData(SocketStream* socket, int amount_sent) override {
358 DeleteJobMaybe(); 358 DeleteJobMaybe();
359 } 359 }
360 360
361 virtual void OnReceivedData(SocketStream* socket, 361 virtual void OnReceivedData(SocketStream* socket,
362 const char* data, 362 const char* data,
363 int len) OVERRIDE { 363 int len) override {
364 DeleteJobMaybe(); 364 DeleteJobMaybe();
365 } 365 }
366 366
367 virtual void OnClose(SocketStream* socket) OVERRIDE { DeleteJobMaybe(); } 367 virtual void OnClose(SocketStream* socket) override { DeleteJobMaybe(); }
368 368
369 virtual void OnAuthRequired(SocketStream* socket, 369 virtual void OnAuthRequired(SocketStream* socket,
370 AuthChallengeInfo* auth_info) OVERRIDE { 370 AuthChallengeInfo* auth_info) override {
371 DeleteJobMaybe(); 371 DeleteJobMaybe();
372 } 372 }
373 373
374 virtual void OnSSLCertificateError(SocketStream* socket, 374 virtual void OnSSLCertificateError(SocketStream* socket,
375 const SSLInfo& ssl_info, 375 const SSLInfo& ssl_info,
376 bool fatal) OVERRIDE { 376 bool fatal) override {
377 DeleteJobMaybe(); 377 DeleteJobMaybe();
378 } 378 }
379 379
380 virtual void OnError(const SocketStream* socket, int error) OVERRIDE { 380 virtual void OnError(const SocketStream* socket, int error) override {
381 DeleteJobMaybe(); 381 DeleteJobMaybe();
382 } 382 }
383 383
384 // CanGetCookies() and CanSetCookies() do not appear to be able to delete the 384 // CanGetCookies() and CanSetCookies() do not appear to be able to delete the
385 // WebSocketJob object. 385 // WebSocketJob object.
386 386
387 private: 387 private:
388 scoped_refptr<WebSocketJob> job_; 388 scoped_refptr<WebSocketJob> job_;
389 bool delete_next_; 389 bool delete_next_;
390 }; 390 };
391 391
392 } // namespace 392 } // namespace
393 393
394 class WebSocketJobTest : public PlatformTest, 394 class WebSocketJobTest : public PlatformTest,
395 public ::testing::WithParamInterface<NextProto> { 395 public ::testing::WithParamInterface<NextProto> {
396 public: 396 public:
397 WebSocketJobTest() 397 WebSocketJobTest()
398 : spdy_util_(GetParam()), 398 : spdy_util_(GetParam()),
399 enable_websocket_over_spdy_(false) {} 399 enable_websocket_over_spdy_(false) {}
400 400
401 virtual void SetUp() OVERRIDE { 401 virtual void SetUp() override {
402 stream_type_ = STREAM_INVALID; 402 stream_type_ = STREAM_INVALID;
403 cookie_store_ = new MockCookieStore; 403 cookie_store_ = new MockCookieStore;
404 context_.reset(new MockURLRequestContext(cookie_store_.get())); 404 context_.reset(new MockURLRequestContext(cookie_store_.get()));
405 } 405 }
406 virtual void TearDown() OVERRIDE { 406 virtual void TearDown() override {
407 cookie_store_ = NULL; 407 cookie_store_ = NULL;
408 context_.reset(); 408 context_.reset();
409 websocket_ = NULL; 409 websocket_ = NULL;
410 socket_ = NULL; 410 socket_ = NULL;
411 } 411 }
412 void DoSendRequest() { 412 void DoSendRequest() {
413 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie, 413 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie,
414 kHandshakeRequestWithoutCookieLength)); 414 kHandshakeRequestWithoutCookieLength));
415 } 415 }
416 void DoSendData() { 416 void DoSendData() {
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 job()->Connect(); 1285 job()->Connect();
1286 SetDeleteNext(); 1286 SetDeleteNext();
1287 job()->OnReceivedData( 1287 job()->OnReceivedData(
1288 socket_.get(), kMinimalResponse, arraysize(kMinimalResponse) - 1); 1288 socket_.get(), kMinimalResponse, arraysize(kMinimalResponse) - 1);
1289 EXPECT_FALSE(job()); 1289 EXPECT_FALSE(job());
1290 } 1290 }
1291 1291
1292 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. 1292 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation.
1293 // TODO(toyoshim,yutak): Add tests to verify closing handshake. 1293 // TODO(toyoshim,yutak): Add tests to verify closing handshake.
1294 } // namespace net 1294 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_job.h ('k') | net/websockets/websocket_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698