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

Side by Side Diff: chrome/browser/devtools/devtools_adb_bridge.cc

Issue 16295003: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/devtools/devtools_adb_bridge.h" 5 #include "chrome/browser/devtools/devtools_adb_bridge.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
363 adb_thread_->message_loop()->PostTask( 363 adb_thread_->message_loop()->PostTask(
364 FROM_HERE, 364 FROM_HERE,
365 base::Bind(&AgentHostDelegate::SendFrameOnHandlerThread, this, 365 base::Bind(&AgentHostDelegate::SendFrameOnHandlerThread, this,
366 message)); 366 message));
367 } 367 }
368 368
369 void StartListeningOnHandlerThread() { 369 void StartListeningOnHandlerThread() {
370 scoped_refptr<net::IOBuffer> response_buffer = 370 scoped_refptr<net::IOBuffer> response_buffer =
371 new net::IOBuffer(kBufferSize); 371 new net::IOBuffer(kBufferSize);
372 int result = socket_->Read(response_buffer, kBufferSize, 372 int result = socket_->Read(
373 response_buffer.get(),
374 kBufferSize,
373 base::Bind(&AgentHostDelegate::OnBytesRead, this, response_buffer)); 375 base::Bind(&AgentHostDelegate::OnBytesRead, this, response_buffer));
374 if (result != net::ERR_IO_PENDING) 376 if (result != net::ERR_IO_PENDING)
375 OnBytesRead(response_buffer, result); 377 OnBytesRead(response_buffer, result);
376 } 378 }
377 379
378 void OnBytesRead(scoped_refptr<net::IOBuffer> response_buffer, int result) { 380 void OnBytesRead(scoped_refptr<net::IOBuffer> response_buffer, int result) {
379 if (!socket_) 381 if (!socket_)
380 return; 382 return;
381 383
382 if (result <= 0) { 384 if (result <= 0) {
(...skipping 18 matching lines...) Expand all
401 parse_result = WebSocket::DecodeFrameHybi17( 403 parse_result = WebSocket::DecodeFrameHybi17(
402 response_buffer_, false, &bytes_consumed, &output); 404 response_buffer_, false, &bytes_consumed, &output);
403 } 405 }
404 406
405 if (parse_result == WebSocket::FRAME_ERROR || 407 if (parse_result == WebSocket::FRAME_ERROR ||
406 parse_result == WebSocket::FRAME_CLOSE) { 408 parse_result == WebSocket::FRAME_CLOSE) {
407 CloseIfNecessary(net::ERR_CONNECTION_CLOSED); 409 CloseIfNecessary(net::ERR_CONNECTION_CLOSED);
408 return; 410 return;
409 } 411 }
410 412
411 result = socket_->Read(response_buffer, kBufferSize, 413 result = socket_->Read(
414 response_buffer.get(),
415 kBufferSize,
412 base::Bind(&AgentHostDelegate::OnBytesRead, this, response_buffer)); 416 base::Bind(&AgentHostDelegate::OnBytesRead, this, response_buffer));
413 if (result != net::ERR_IO_PENDING) 417 if (result != net::ERR_IO_PENDING)
414 OnBytesRead(response_buffer, result); 418 OnBytesRead(response_buffer, result);
415 } 419 }
416 420
417 void SendFrameOnHandlerThread(const std::string& data) { 421 void SendFrameOnHandlerThread(const std::string& data) {
418 tethering_adb_filter_.ProcessOutgoingMessage(data); 422 tethering_adb_filter_.ProcessOutgoingMessage(data);
419 int mask = base::RandInt(0, 0x7FFFFFFF); 423 int mask = base::RandInt(0, 0x7FFFFFFF);
420 std::string encoded_frame = WebSocket::EncodeFrameHybi17(data, mask); 424 std::string encoded_frame = WebSocket::EncodeFrameHybi17(data, mask);
421 scoped_refptr<net::StringIOBuffer> request_buffer = 425 scoped_refptr<net::StringIOBuffer> request_buffer =
422 new net::StringIOBuffer(encoded_frame); 426 new net::StringIOBuffer(encoded_frame);
423 if (!socket_) 427 if (!socket_)
424 return; 428 return;
425 int result = socket_->Write(request_buffer, request_buffer->size(), 429 int result =
426 base::Bind(&AgentHostDelegate::CloseIfNecessary, this)); 430 socket_->Write(request_buffer.get(),
431 request_buffer->size(),
432 base::Bind(&AgentHostDelegate::CloseIfNecessary, this));
427 if (result != net::ERR_IO_PENDING) 433 if (result != net::ERR_IO_PENDING)
428 CloseIfNecessary(result); 434 CloseIfNecessary(result);
429 } 435 }
430 436
431 void CloseConnection(int result, bool initiated_by_me) { 437 void CloseConnection(int result, bool initiated_by_me) {
432 if (!socket_) 438 if (!socket_)
433 return; 439 return;
434 socket_->Disconnect(); 440 socket_->Disconnect();
435 socket_.reset(); 441 socket_.reset();
436 if (initiated_by_me) { 442 if (initiated_by_me) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 if (!has_message_loop_) 653 if (!has_message_loop_)
648 return; 654 return;
649 655
650 scoped_refptr<AdbAttachCommand> command( 656 scoped_refptr<AdbAttachCommand> command(
651 new AdbAttachCommand(weak_factory_.GetWeakPtr(), serial, socket, 657 new AdbAttachCommand(weak_factory_.GetWeakPtr(), serial, socket,
652 debug_url, frontend_url)); 658 debug_url, frontend_url));
653 adb_thread_->message_loop()->PostTask( 659 adb_thread_->message_loop()->PostTask(
654 FROM_HERE, 660 FROM_HERE,
655 base::Bind(&AdbAttachCommand::Run, command)); 661 base::Bind(&AdbAttachCommand::Run, command));
656 } 662 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/adb_client_socket.cc ('k') | chrome/browser/devtools/devtools_sanity_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698