| 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/client/plugin/pepper_view.h" | 5 #include "remoting/client/plugin/pepper_view.h" |
| 6 | 6 |
| 7 #include <functional> | 7 #include <functional> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 using base::Passed; | 25 using base::Passed; |
| 26 | 26 |
| 27 namespace remoting { | 27 namespace remoting { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // The maximum number of image buffers to be allocated at any point of time. | 31 // The maximum number of image buffers to be allocated at any point of time. |
| 32 const size_t kMaxPendingBuffersCount = 2; | 32 const size_t kMaxPendingBuffersCount = 2; |
| 33 | 33 |
| 34 ChromotingInstance::ConnectionError ConvertConnectionError( | 34 ChromotingInstance::ConnectionError ConvertConnectionError( |
| 35 protocol::ConnectionToHost::Error error) { | 35 protocol::ErrorCode error) { |
| 36 switch (error) { | 36 switch (error) { |
| 37 case protocol::ConnectionToHost::OK: | 37 case protocol::OK: |
| 38 return ChromotingInstance::ERROR_NONE; | 38 return ChromotingInstance::ERROR_NONE; |
| 39 case protocol::ConnectionToHost::HOST_IS_OFFLINE: | 39 |
| 40 case protocol::PEER_IS_OFFLINE: |
| 40 return ChromotingInstance::ERROR_HOST_IS_OFFLINE; | 41 return ChromotingInstance::ERROR_HOST_IS_OFFLINE; |
| 41 case protocol::ConnectionToHost::SESSION_REJECTED: | 42 |
| 43 case protocol::SESSION_REJECTED: |
| 44 case protocol::AUTHENTICATION_FAILED: |
| 42 return ChromotingInstance::ERROR_SESSION_REJECTED; | 45 return ChromotingInstance::ERROR_SESSION_REJECTED; |
| 43 case protocol::ConnectionToHost::INCOMPATIBLE_PROTOCOL: | 46 |
| 47 case protocol::INCOMPATIBLE_PROTOCOL: |
| 44 return ChromotingInstance::ERROR_INCOMPATIBLE_PROTOCOL; | 48 return ChromotingInstance::ERROR_INCOMPATIBLE_PROTOCOL; |
| 45 case protocol::ConnectionToHost::NETWORK_FAILURE: | 49 |
| 50 case protocol::CHANNEL_CONNECTION_ERROR: |
| 51 case protocol::SIGNALING_TIMEOUT: |
| 52 case protocol::UNKNOWN_ERROR: |
| 46 return ChromotingInstance::ERROR_NETWORK_FAILURE; | 53 return ChromotingInstance::ERROR_NETWORK_FAILURE; |
| 47 } | 54 } |
| 48 DLOG(FATAL) << "Unknown error code" << error; | 55 DLOG(FATAL) << "Unknown error code" << error; |
| 49 return ChromotingInstance::ERROR_NONE; | 56 return ChromotingInstance::ERROR_NONE; |
| 50 } | 57 } |
| 51 | 58 |
| 52 } // namespace | 59 } // namespace |
| 53 | 60 |
| 54 PepperView::PepperView(ChromotingInstance* instance, | 61 PepperView::PepperView(ChromotingInstance* instance, |
| 55 ClientContext* context, | 62 ClientContext* context, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 97 |
| 91 merge_buffer_ = NULL; | 98 merge_buffer_ = NULL; |
| 92 while (!buffers_.empty()) { | 99 while (!buffers_.empty()) { |
| 93 FreeBuffer(buffers_.front()); | 100 FreeBuffer(buffers_.front()); |
| 94 } | 101 } |
| 95 | 102 |
| 96 weak_factory_.InvalidateWeakPtrs(); | 103 weak_factory_.InvalidateWeakPtrs(); |
| 97 } | 104 } |
| 98 | 105 |
| 99 void PepperView::SetConnectionState(protocol::ConnectionToHost::State state, | 106 void PepperView::SetConnectionState(protocol::ConnectionToHost::State state, |
| 100 protocol::ConnectionToHost::Error error) { | 107 protocol::ErrorCode error) { |
| 101 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); | 108 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); |
| 102 | 109 |
| 103 switch (state) { | 110 switch (state) { |
| 104 case protocol::ConnectionToHost::CONNECTING: | 111 case protocol::ConnectionToHost::CONNECTING: |
| 105 instance_->SetConnectionState( | 112 instance_->SetConnectionState( |
| 106 ChromotingInstance::STATE_CONNECTING, | 113 ChromotingInstance::STATE_CONNECTING, |
| 107 ConvertConnectionError(error)); | 114 ConvertConnectionError(error)); |
| 108 break; | 115 break; |
| 109 | 116 |
| 110 case protocol::ConnectionToHost::CONNECTED: | 117 case protocol::ConnectionToHost::CONNECTED: |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 // Resume painting for the buffer that was previoulsy postponed because of | 362 // Resume painting for the buffer that was previoulsy postponed because of |
| 356 // pending flush. | 363 // pending flush. |
| 357 if (merge_buffer_ != NULL) { | 364 if (merge_buffer_ != NULL) { |
| 358 buffer = merge_buffer_; | 365 buffer = merge_buffer_; |
| 359 merge_buffer_ = NULL; | 366 merge_buffer_ = NULL; |
| 360 FlushBuffer(merge_clip_area_, buffer, merge_region_); | 367 FlushBuffer(merge_clip_area_, buffer, merge_region_); |
| 361 } | 368 } |
| 362 } | 369 } |
| 363 | 370 |
| 364 } // namespace remoting | 371 } // namespace remoting |
| OLD | NEW |