diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-04 19:48:42 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-04 19:48:42 +0000 |
commit | 8ea7a167522a24be192e958af46a41d49e78504c (patch) | |
tree | 571cf839290beed90019a744c3a096be89cc67d1 /remoting/client/chromoting_view.cc | |
parent | b552f1787ca864e458e4c14e6012c20b423161a5 (diff) | |
download | chromium_src-8ea7a167522a24be192e958af46a41d49e78504c.zip chromium_src-8ea7a167522a24be192e958af46a41d49e78504c.tar.gz chromium_src-8ea7a167522a24be192e958af46a41d49e78504c.tar.bz2 |
This is a monster CL.
It started as an attempt to put the decoder onto another thread. However, this became complicated due to multiple object ownership transfers and coupling between the decode layer and the network layer; the decoder's states were highly coupled with how the network packets were processed.
This could probably be broken up slightly, but at this point, it's easier to just commit as a whole The refactor includes:
1) Making the decoder interface unaware of "network packet" types.
2) Making the network layer process packets in order.
3) Threading through asynchronous APIs all over the place.
4) Simplifying the rectangle update protocol.
5) Cleaning up object lifetime and ownership semantics between the decode layer and the renderer.
As of right now, the Verbatim format is still broken on the encode side because it uses the old protocol.
BUG=52883, 57351
TEST=still connects to chromoting_simple_host
Review URL: http://codereview.chromium.org/3305001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/chromoting_view.cc')
-rw-r--r-- | remoting/client/chromoting_view.cc | 92 |
1 files changed, 3 insertions, 89 deletions
diff --git a/remoting/client/chromoting_view.cc b/remoting/client/chromoting_view.cc index 95d2dfa..ba34a5d 100644 --- a/remoting/client/chromoting_view.cc +++ b/remoting/client/chromoting_view.cc @@ -4,8 +4,9 @@ #include "remoting/client/chromoting_view.h" -#include "remoting/base/decoder_verbatim.h" -#include "remoting/base/decoder_zlib.h" +#include "base/message_loop.h" +#include "base/waitable_event.h" +#include "remoting/base/tracer.h" namespace remoting { @@ -14,7 +15,6 @@ ChromotingView::ChromotingView() frame_height_(0) { } - // TODO(garykac): This assumes a single screen. This will need to be adjusted // to add support for mulitple monitors. void ChromotingView::GetScreenSize(int* width, int* height) { @@ -22,90 +22,4 @@ void ChromotingView::GetScreenSize(int* width, int* height) { *height = frame_height_; } -bool ChromotingView::SetupDecoder(UpdateStreamEncoding encoding) { - if (encoding == EncodingInvalid) { - LOG(ERROR) << "Cannot create encoder for EncodingInvalid"; - return false; - } - - // If we're in the middle of decoding a stream, then we need to make sure - // that that all packets in that stream match the encoding of the first - // packet. - // - // If we decide to relax this constraint in the future, we'll need to - // update this to keep a set of decoders around. - if (decoder_.get() && decoder_->IsStarted()) { - // Verify that the encoding matches the decoder. Once we've started - // decoding, we can't switch to another decoder. - if (decoder_->Encoding() != encoding) { - LOG(ERROR) << "Encoding mismatch: Set up to handle " - << "UpdateStreamEncoding=" << decoder_->Encoding() - << " but received request for " - << encoding; - return false; - } - return true; - } - - // Lazily initialize a new decoder. - // We create a new decoder if we don't currently have a decoder or if the - // decoder doesn't match the desired encoding. - if (!decoder_.get() || decoder_->Encoding() != encoding) { - // Initialize a new decoder based on this message encoding. - if (encoding == EncodingNone) { - decoder_.reset(new DecoderVerbatim()); - } else if (encoding == EncodingZlib) { - decoder_.reset(new DecoderZlib()); - } - // Make sure we successfully allocated a decoder of the correct type. - DCHECK(decoder_.get()); - DCHECK(decoder_->Encoding() == encoding); - } - - return true; -} - -bool ChromotingView::BeginDecoding(Task* partial_decode_done, - Task* decode_done) { - if (decoder_->IsStarted()) { - LOG(ERROR) << "BeginDecoding called without ending previous decode."; - return false; - } - - decoder_->BeginDecode(frame_, &update_rects_, - partial_decode_done, decode_done); - - if (!decoder_->IsStarted()) { - LOG(ERROR) << "Unable to start decoding."; - return false; - } - - return true; -} - -bool ChromotingView::Decode(ChromotingHostMessage* msg) { - if (!decoder_->IsStarted()) { - LOG(ERROR) << "Attempt to decode payload before calling BeginDecode."; - return false; - } - - return decoder_->PartialDecode(msg); -} - -bool ChromotingView::EndDecoding() { - if (!decoder_->IsStarted()) { - LOG(ERROR) << "Attempt to end decode when none has been started."; - return false; - } - - decoder_->EndDecode(); - - if (decoder_->IsStarted()) { - LOG(ERROR) << "Unable to properly end decoding.\n"; - return false; - } - - return true; -} - } // namespace remoting |