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

Side by Side Diff: remoting/base/socket_reader.cc

Issue 15782010: Update remoting/ and jingle/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « remoting/base/rsa_key_pair_unittest.cc ('k') | remoting/client/chromoting_client.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 (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 "remoting/base/socket_reader.h" 5 #include "remoting/base/socket_reader.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 22 matching lines...) Expand all
33 33
34 socket_ = socket; 34 socket_ = socket;
35 read_result_callback_ = read_result_callback; 35 read_result_callback_ = read_result_callback;
36 DoRead(); 36 DoRead();
37 } 37 }
38 38
39 void SocketReader::DoRead() { 39 void SocketReader::DoRead() {
40 while (true) { 40 while (true) {
41 read_buffer_ = new net::IOBuffer(kReadBufferSize); 41 read_buffer_ = new net::IOBuffer(kReadBufferSize);
42 int result = socket_->Read( 42 int result = socket_->Read(
43 read_buffer_, kReadBufferSize, base::Bind(&SocketReader::OnRead, 43 read_buffer_.get(),
44 weak_factory_.GetWeakPtr())); 44 kReadBufferSize,
45 base::Bind(&SocketReader::OnRead, weak_factory_.GetWeakPtr()));
45 HandleReadResult(result); 46 HandleReadResult(result);
46 if (result <= 0) 47 if (result <= 0)
47 break; 48 break;
48 } 49 }
49 } 50 }
50 51
51 void SocketReader::OnRead(int result) { 52 void SocketReader::OnRead(int result) {
52 HandleReadResult(result); 53 HandleReadResult(result);
53 if (result > 0) 54 if (result > 0)
54 DoRead(); 55 DoRead();
55 } 56 }
56 57
57 void SocketReader::HandleReadResult(int result) { 58 void SocketReader::HandleReadResult(int result) {
58 if (result != net::ERR_IO_PENDING) { 59 if (result != net::ERR_IO_PENDING) {
59 if (result < 0) 60 if (result < 0)
60 read_buffer_ = NULL; 61 read_buffer_ = NULL;
61 base::ThreadTaskRunnerHandle::Get()->PostTask( 62 base::ThreadTaskRunnerHandle::Get()->PostTask(
62 FROM_HERE, 63 FROM_HERE,
63 base::Bind(&SocketReader::CallCallback, weak_factory_.GetWeakPtr(), 64 base::Bind(&SocketReader::CallCallback, weak_factory_.GetWeakPtr(),
64 read_buffer_, result)); 65 read_buffer_, result));
65 } 66 }
66 } 67 }
67 68
68 void SocketReader::CallCallback(scoped_refptr<net::IOBuffer> data, int result) { 69 void SocketReader::CallCallback(scoped_refptr<net::IOBuffer> data, int result) {
69 read_result_callback_.Run(data, result); 70 read_result_callback_.Run(data, result);
70 } 71 }
71 72
72 } // namespace remoting 73 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/rsa_key_pair_unittest.cc ('k') | remoting/client/chromoting_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698