| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/net/blimp_message_pump.h" | 5 #include "blimp/net/blimp_message_pump.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "blimp/common/logging.h" | 8 #include "blimp/common/logging.h" |
| 9 #include "blimp/common/proto/blimp_message.pb.h" | 9 #include "blimp/common/proto/blimp_message.pb.h" |
| 10 #include "blimp/net/blimp_message_processor.h" | 10 #include "blimp/net/blimp_message_processor.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 weak_factory_.GetWeakPtr())); | 49 weak_factory_.GetWeakPtr())); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void BlimpMessagePump::OnReadPacketComplete(int result) { | 52 void BlimpMessagePump::OnReadPacketComplete(int result) { |
| 53 DVLOG(2) << "OnReadPacketComplete, result=" << result; | 53 DVLOG(2) << "OnReadPacketComplete, result=" << result; |
| 54 DCHECK(read_inflight_); | 54 DCHECK(read_inflight_); |
| 55 read_inflight_ = false; | 55 read_inflight_ = false; |
| 56 if (result >= 0) { | 56 if (result >= 0) { |
| 57 scoped_ptr<BlimpMessage> message(new BlimpMessage); | 57 scoped_ptr<BlimpMessage> message(new BlimpMessage); |
| 58 if (message->ParseFromArray(buffer_->data(), result)) { | 58 if (message->ParseFromArray(buffer_->data(), result)) { |
| 59 DVLOG(2) << "OnReadPacketComplete, result=" << *message; | 59 VLOG(1) << "Received " << *message; |
| 60 processor_->ProcessMessage( | 60 processor_->ProcessMessage( |
| 61 std::move(message), | 61 std::move(message), |
| 62 base::Bind(&BlimpMessagePump::OnProcessMessageComplete, | 62 base::Bind(&BlimpMessagePump::OnProcessMessageComplete, |
| 63 weak_factory_.GetWeakPtr())); | 63 weak_factory_.GetWeakPtr())); |
| 64 } else { | 64 } else { |
| 65 result = net::ERR_FAILED; | 65 result = net::ERR_FAILED; |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 if (result < 0) { | 69 if (result < 0) { |
| 70 error_observer_->OnConnectionError(result); | 70 error_observer_->OnConnectionError(result); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 void BlimpMessagePump::OnProcessMessageComplete(int result) { | 74 void BlimpMessagePump::OnProcessMessageComplete(int result) { |
| 75 DVLOG(2) << "OnProcessMessageComplete, result=" << result; | 75 DVLOG(2) << "OnProcessMessageComplete, result=" << result; |
| 76 | 76 |
| 77 if (result < 0) { | 77 if (result < 0) { |
| 78 error_observer_->OnConnectionError(result); | 78 error_observer_->OnConnectionError(result); |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 | 81 |
| 82 if (processor_) | 82 if (processor_) |
| 83 ReadNextPacket(); | 83 ReadNextPacket(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace blimp | 86 } // namespace blimp |
| OLD | NEW |