| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/host/fake_host_extension.h" | 5 #include "remoting/host/fake_host_extension.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "remoting/codec/video_encoder.h" | 12 #include "remoting/host/client_session_details.h" |
| 13 #include "remoting/host/host_extension_session.h" | 13 #include "remoting/host/host_extension_session.h" |
| 14 #include "remoting/proto/control.pb.h" | 14 #include "remoting/proto/control.pb.h" |
| 15 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" | |
| 16 | 15 |
| 17 namespace remoting { | 16 namespace remoting { |
| 18 | 17 |
| 19 class FakeExtension::Session : public HostExtensionSession { | 18 class FakeExtension::Session : public HostExtensionSession { |
| 20 public: | 19 public: |
| 21 Session(FakeExtension* extension, const std::string& message_type); | 20 Session(FakeExtension* extension, const std::string& message_type); |
| 22 ~Session() override {} | 21 ~Session() override {} |
| 23 | 22 |
| 24 // HostExtensionSession interface. | 23 // HostExtensionSession interface. |
| 25 bool OnExtensionMessage(ClientSessionControl* client_session_control, | 24 bool OnExtensionMessage(ClientSessionDetails* client_session_details, |
| 26 protocol::ClientStub* client_stub, | 25 protocol::ClientStub* client_stub, |
| 27 const protocol::ExtensionMessage& message) override; | 26 const protocol::ExtensionMessage& message) override; |
| 28 | 27 |
| 29 private: | 28 private: |
| 30 FakeExtension* extension_; | 29 FakeExtension* extension_; |
| 31 std::string message_type_; | 30 std::string message_type_; |
| 32 | 31 |
| 33 DISALLOW_COPY_AND_ASSIGN(Session); | 32 DISALLOW_COPY_AND_ASSIGN(Session); |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 FakeExtension::Session::Session(FakeExtension* extension, | 35 FakeExtension::Session::Session(FakeExtension* extension, |
| 37 const std::string& message_type) | 36 const std::string& message_type) |
| 38 : extension_(extension), message_type_(message_type) {} | 37 : extension_(extension), message_type_(message_type) {} |
| 39 | 38 |
| 40 bool FakeExtension::Session::OnExtensionMessage( | 39 bool FakeExtension::Session::OnExtensionMessage( |
| 41 ClientSessionControl* client_session_control, | 40 ClientSessionDetails* client_session_details, |
| 42 protocol::ClientStub* client_stub, | 41 protocol::ClientStub* client_stub, |
| 43 const protocol::ExtensionMessage& message) { | 42 const protocol::ExtensionMessage& message) { |
| 44 if (message.type() == message_type_) { | 43 if (message.type() == message_type_) { |
| 45 extension_->has_handled_message_ = true; | 44 extension_->has_handled_message_ = true; |
| 46 return true; | 45 return true; |
| 47 } | 46 } |
| 48 return false; | 47 return false; |
| 49 } | 48 } |
| 50 | 49 |
| 51 FakeExtension::FakeExtension(const std::string& message_type, | 50 FakeExtension::FakeExtension(const std::string& message_type, |
| 52 const std::string& capability) | 51 const std::string& capability) |
| 53 : message_type_(message_type), capability_(capability) {} | 52 : message_type_(message_type), capability_(capability) {} |
| 54 | 53 |
| 55 FakeExtension::~FakeExtension() {} | 54 FakeExtension::~FakeExtension() {} |
| 56 | 55 |
| 57 std::string FakeExtension::capability() const { | 56 std::string FakeExtension::capability() const { |
| 58 return capability_; | 57 return capability_; |
| 59 } | 58 } |
| 60 | 59 |
| 61 std::unique_ptr<HostExtensionSession> FakeExtension::CreateExtensionSession( | 60 std::unique_ptr<HostExtensionSession> FakeExtension::CreateExtensionSession( |
| 62 ClientSessionControl* client_session_control, | 61 ClientSessionDetails* client_session_details, |
| 63 protocol::ClientStub* client_stub) { | 62 protocol::ClientStub* client_stub) { |
| 64 DCHECK(!was_instantiated()); | 63 DCHECK(!was_instantiated()); |
| 65 was_instantiated_ = true; | 64 was_instantiated_ = true; |
| 66 return base::WrapUnique(new Session(this, message_type_)); | 65 return base::WrapUnique(new Session(this, message_type_)); |
| 67 } | 66 } |
| 68 | 67 |
| 69 } // namespace remoting | 68 } // namespace remoting |
| OLD | NEW |