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

Side by Side Diff: remoting/client/chromoting_view.cc

Issue 3124005: Move UpdateStreamEncoding value into the BeginUpdateStreamMessage since we... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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/chromoting_view.h ('k') | remoting/client/chromoting_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/client/chromoting_view.h"
6
7 #include "remoting/base/decoder_verbatim.h"
8 #include "remoting/base/decoder_zlib.h"
9
10 namespace remoting {
11
12 ChromotingView::ChromotingView()
13 : frame_width_(0),
14 frame_height_(0) {
15 }
16
17 bool ChromotingView::SetupDecoder(UpdateStreamEncoding encoding) {
18 if (encoding == EncodingInvalid) {
19 LOG(ERROR) << "Cannot create encoder for EncodingInvalid";
20 return false;
21 }
22
23 // If we're in the middle of decoding a stream, then we need to make sure
24 // that that all packets in that stream match the encoding of the first
25 // packet.
26 //
27 // If we decide to relax this constraint in the future, we'll need to
28 // update this to keep a set of decoders around.
29 if (decoder_.get() && decoder_->IsStarted()) {
30 // Verify that the encoding matches the decoder. Once we've started
31 // decoding, we can't switch to another decoder.
32 if (decoder_->Encoding() != encoding) {
33 LOG(ERROR) << "Encoding mismatch: Set up to handle "
34 << "UpdateStreamEncoding=" << decoder_->Encoding()
35 << " but received request for "
36 << encoding;
37 return false;
38 }
39 return true;
40 }
41
42 // Lazily initialize a new decoder.
43 // We create a new decoder if we don't currently have a decoder or if the
44 // decoder doesn't match the desired encoding.
45 if (!decoder_.get() || decoder_->Encoding() != encoding) {
46 // Initialize a new decoder based on this message encoding.
47 if (encoding == EncodingNone) {
48 decoder_.reset(new DecoderVerbatim());
49 } else if (encoding == EncodingZlib) {
50 decoder_.reset(new DecoderZlib());
51 }
52 // Make sure we successfully allocated a decoder of the correct type.
53 DCHECK(decoder_.get());
54 DCHECK(decoder_->Encoding() == encoding);
55 }
56
57 return true;
58 }
59
60 bool ChromotingView::BeginDecoding(Task* partial_decode_done,
61 Task* decode_done) {
62 if (decoder_->IsStarted()) {
63 LOG(ERROR) << "BeginDecoding called without ending previous decode.";
64 return false;
65 }
66
67 decoder_->BeginDecode(frame_, &update_rects_,
68 partial_decode_done, decode_done);
69
70 if (!decoder_->IsStarted()) {
71 LOG(ERROR) << "Unable to start decoding.";
72 return false;
73 }
74
75 return true;
76 }
77
78 bool ChromotingView::Decode(HostMessage* msg) {
79 if (!decoder_->IsStarted()) {
80 LOG(ERROR) << "Attempt to decode payload before calling BeginDecode.";
81 return false;
82 }
83
84 return decoder_->PartialDecode(msg);
85 }
86
87 bool ChromotingView::EndDecoding() {
88 if (!decoder_->IsStarted()) {
89 LOG(ERROR) << "Attempt to end decode when none has been started.";
90 return false;
91 }
92
93 decoder_->EndDecode();
94
95 if (decoder_->IsStarted()) {
96 LOG(ERROR) << "Unable to properly end decoding.\n";
97 return false;
98 }
99
100 return true;
101 }
102
103 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/chromoting_view.h ('k') | remoting/client/chromoting_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698