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

Side by Side Diff: remoting/client/plugin/pepper_view.cc

Issue 9567033: Cleanup error handling in the client plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 9 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/client/plugin/pepper_view.h ('k') | remoting/host/client_session.h » ('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/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 13 matching lines...) Expand all
24 24
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 // TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp
35 // and let it handle it, but it would be hard to fix it now because
36 // client plugin and webapp versions may not be in sync. It should be
37 // easy to do after we are finished moving the client plugin to NaCl.
34 ChromotingInstance::ConnectionError ConvertConnectionError( 38 ChromotingInstance::ConnectionError ConvertConnectionError(
35 protocol::ConnectionToHost::Error error) { 39 protocol::ErrorCode error) {
36 switch (error) { 40 switch (error) {
37 case protocol::ConnectionToHost::OK: 41 case protocol::OK:
38 return ChromotingInstance::ERROR_NONE; 42 return ChromotingInstance::ERROR_NONE;
39 case protocol::ConnectionToHost::HOST_IS_OFFLINE: 43
44 case protocol::PEER_IS_OFFLINE:
40 return ChromotingInstance::ERROR_HOST_IS_OFFLINE; 45 return ChromotingInstance::ERROR_HOST_IS_OFFLINE;
41 case protocol::ConnectionToHost::SESSION_REJECTED: 46
47 case protocol::SESSION_REJECTED:
48 case protocol::AUTHENTICATION_FAILED:
42 return ChromotingInstance::ERROR_SESSION_REJECTED; 49 return ChromotingInstance::ERROR_SESSION_REJECTED;
43 case protocol::ConnectionToHost::INCOMPATIBLE_PROTOCOL: 50
51 case protocol::INCOMPATIBLE_PROTOCOL:
44 return ChromotingInstance::ERROR_INCOMPATIBLE_PROTOCOL; 52 return ChromotingInstance::ERROR_INCOMPATIBLE_PROTOCOL;
45 case protocol::ConnectionToHost::NETWORK_FAILURE: 53
54 case protocol::CHANNEL_CONNECTION_ERROR:
55 case protocol::SIGNALING_ERROR:
56 case protocol::SIGNALING_TIMEOUT:
57 case protocol::UNKNOWN_ERROR:
46 return ChromotingInstance::ERROR_NETWORK_FAILURE; 58 return ChromotingInstance::ERROR_NETWORK_FAILURE;
47 } 59 }
48 DLOG(FATAL) << "Unknown error code" << error; 60 DLOG(FATAL) << "Unknown error code" << error;
49 return ChromotingInstance::ERROR_NONE; 61 return ChromotingInstance::ERROR_NONE;
50 } 62 }
51 63
52 } // namespace 64 } // namespace
53 65
54 PepperView::PepperView(ChromotingInstance* instance, 66 PepperView::PepperView(ChromotingInstance* instance,
55 ClientContext* context, 67 ClientContext* context,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 102
91 merge_buffer_ = NULL; 103 merge_buffer_ = NULL;
92 while (!buffers_.empty()) { 104 while (!buffers_.empty()) {
93 FreeBuffer(buffers_.front()); 105 FreeBuffer(buffers_.front());
94 } 106 }
95 107
96 weak_factory_.InvalidateWeakPtrs(); 108 weak_factory_.InvalidateWeakPtrs();
97 } 109 }
98 110
99 void PepperView::SetConnectionState(protocol::ConnectionToHost::State state, 111 void PepperView::SetConnectionState(protocol::ConnectionToHost::State state,
100 protocol::ConnectionToHost::Error error) { 112 protocol::ErrorCode error) {
101 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); 113 DCHECK(context_->main_message_loop()->BelongsToCurrentThread());
102 114
103 switch (state) { 115 switch (state) {
104 case protocol::ConnectionToHost::CONNECTING: 116 case protocol::ConnectionToHost::CONNECTING:
105 instance_->SetConnectionState( 117 instance_->SetConnectionState(
106 ChromotingInstance::STATE_CONNECTING, 118 ChromotingInstance::STATE_CONNECTING,
107 ConvertConnectionError(error)); 119 ConvertConnectionError(error));
108 break; 120 break;
109 121
110 case protocol::ConnectionToHost::CONNECTED: 122 case protocol::ConnectionToHost::CONNECTED:
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // Resume painting for the buffer that was previoulsy postponed because of 367 // Resume painting for the buffer that was previoulsy postponed because of
356 // pending flush. 368 // pending flush.
357 if (merge_buffer_ != NULL) { 369 if (merge_buffer_ != NULL) {
358 buffer = merge_buffer_; 370 buffer = merge_buffer_;
359 merge_buffer_ = NULL; 371 merge_buffer_ = NULL;
360 FlushBuffer(merge_clip_area_, buffer, merge_region_); 372 FlushBuffer(merge_clip_area_, buffer, merge_region_);
361 } 373 }
362 } 374 }
363 375
364 } // namespace remoting 376 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_view.h ('k') | remoting/host/client_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698