| OLD | NEW |
| 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/protocol/message_reader.h" | 5 #include "remoting/protocol/message_reader.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 14 #include "base/single_thread_task_runner.h" | |
| 15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 17 #include "remoting/base/compound_buffer.h" | 18 #include "remoting/base/compound_buffer.h" |
| 18 #include "remoting/proto/internal.pb.h" | 19 #include "remoting/proto/internal.pb.h" |
| 19 #include "remoting/protocol/p2p_stream_socket.h" | 20 #include "remoting/protocol/p2p_stream_socket.h" |
| 20 | 21 |
| 21 namespace remoting { | 22 namespace remoting { |
| 22 namespace protocol { | 23 namespace protocol { |
| 23 | 24 |
| 24 static const int kReadBufferSize = 4096; | 25 static const int kReadBufferSize = 4096; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 102 |
| 102 // Get list of all new messages first, and then call the callback | 103 // Get list of all new messages first, and then call the callback |
| 103 // for all of them. | 104 // for all of them. |
| 104 while (true) { | 105 while (true) { |
| 105 CompoundBuffer* buffer = message_decoder_.GetNextMessage(); | 106 CompoundBuffer* buffer = message_decoder_.GetNextMessage(); |
| 106 if (!buffer) | 107 if (!buffer) |
| 107 break; | 108 break; |
| 108 base::ThreadTaskRunnerHandle::Get()->PostTask( | 109 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 109 FROM_HERE, | 110 FROM_HERE, |
| 110 base::Bind(&MessageReader::RunCallback, weak_factory_.GetWeakPtr(), | 111 base::Bind(&MessageReader::RunCallback, weak_factory_.GetWeakPtr(), |
| 111 base::Passed(make_scoped_ptr(buffer)))); | 112 base::Passed(base::WrapUnique(buffer)))); |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 | 115 |
| 115 void MessageReader::RunCallback(scoped_ptr<CompoundBuffer> message) { | 116 void MessageReader::RunCallback(std::unique_ptr<CompoundBuffer> message) { |
| 116 if (!message_received_callback_.is_null()) | 117 if (!message_received_callback_.is_null()) |
| 117 message_received_callback_.Run(std::move(message)); | 118 message_received_callback_.Run(std::move(message)); |
| 118 } | 119 } |
| 119 | 120 |
| 120 } // namespace protocol | 121 } // namespace protocol |
| 121 } // namespace remoting | 122 } // namespace remoting |
| OLD | NEW |