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/host/desktop_environment.h" | 5 #include "remoting/host/desktop_environment.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "remoting/host/audio_capturer.h" | 9 #include "remoting/host/audio_capturer.h" |
10 #include "remoting/host/capturer.h" | 10 #include "remoting/host/video_frame_capturer.h" |
11 #include "remoting/host/chromoting_host_context.h" | 11 #include "remoting/host/chromoting_host_context.h" |
12 #include "remoting/host/event_executor.h" | 12 #include "remoting/host/event_executor.h" |
13 | 13 |
14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
15 #include "remoting/host/session_event_executor_win.h" | 15 #include "remoting/host/session_event_executor_win.h" |
16 #endif | 16 #endif |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 | 19 |
20 // static | 20 // static |
21 scoped_ptr<DesktopEnvironment> DesktopEnvironment::Create( | 21 scoped_ptr<DesktopEnvironment> DesktopEnvironment::Create( |
22 ChromotingHostContext* context) { | 22 ChromotingHostContext* context) { |
23 scoped_ptr<Capturer> capturer(Capturer::Create()); | 23 scoped_ptr<VideoFrameCapturer> capturer(VideoFrameCapturer::Create()); |
24 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( | 24 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( |
25 context->desktop_task_runner(), context->ui_task_runner(), | 25 context->desktop_task_runner(), context->ui_task_runner(), |
26 capturer.get()); | 26 capturer.get()); |
27 scoped_ptr<AudioCapturer> audio_capturer = AudioCapturer::Create(); | 27 scoped_ptr<AudioCapturer> audio_capturer = AudioCapturer::Create(); |
28 | 28 |
29 if (capturer.get() == NULL || event_executor.get() == NULL) { | 29 if (capturer.get() == NULL || event_executor.get() == NULL) { |
30 LOG(ERROR) << "Unable to create DesktopEnvironment"; | 30 LOG(ERROR) << "Unable to create DesktopEnvironment"; |
31 return scoped_ptr<DesktopEnvironment>(); | 31 return scoped_ptr<DesktopEnvironment>(); |
32 } | 32 } |
33 | 33 |
34 return scoped_ptr<DesktopEnvironment>( | 34 return scoped_ptr<DesktopEnvironment>( |
35 new DesktopEnvironment(context, | 35 new DesktopEnvironment(context, |
36 capturer.Pass(), | 36 capturer.Pass(), |
37 event_executor.Pass(), | 37 event_executor.Pass(), |
38 audio_capturer.Pass())); | 38 audio_capturer.Pass())); |
39 } | 39 } |
40 | 40 |
41 // static | 41 // static |
42 scoped_ptr<DesktopEnvironment> DesktopEnvironment::CreateForService( | 42 scoped_ptr<DesktopEnvironment> DesktopEnvironment::CreateForService( |
43 ChromotingHostContext* context) { | 43 ChromotingHostContext* context) { |
44 scoped_ptr<Capturer> capturer(Capturer::Create()); | 44 scoped_ptr<VideoFrameCapturer> capturer(VideoFrameCapturer::Create()); |
45 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( | 45 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( |
46 context->desktop_task_runner(), context->ui_task_runner(), | 46 context->desktop_task_runner(), context->ui_task_runner(), |
47 capturer.get()); | 47 capturer.get()); |
48 scoped_ptr<AudioCapturer> audio_capturer = AudioCapturer::Create(); | 48 scoped_ptr<AudioCapturer> audio_capturer = AudioCapturer::Create(); |
49 | 49 |
50 if (capturer.get() == NULL || event_executor.get() == NULL) { | 50 if (capturer.get() == NULL || event_executor.get() == NULL) { |
51 LOG(ERROR) << "Unable to create DesktopEnvironment"; | 51 LOG(ERROR) << "Unable to create DesktopEnvironment"; |
52 return scoped_ptr<DesktopEnvironment>(); | 52 return scoped_ptr<DesktopEnvironment>(); |
53 } | 53 } |
54 | 54 |
55 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
56 event_executor.reset(new SessionEventExecutorWin( | 56 event_executor.reset(new SessionEventExecutorWin( |
57 context->desktop_task_runner(), | 57 context->desktop_task_runner(), |
58 context->file_task_runner(), | 58 context->file_task_runner(), |
59 event_executor.Pass())); | 59 event_executor.Pass())); |
60 #endif | 60 #endif |
61 | 61 |
62 return scoped_ptr<DesktopEnvironment>( | 62 return scoped_ptr<DesktopEnvironment>( |
63 new DesktopEnvironment(context, | 63 new DesktopEnvironment(context, |
64 capturer.Pass(), | 64 capturer.Pass(), |
65 event_executor.Pass(), | 65 event_executor.Pass(), |
66 audio_capturer.Pass())); | 66 audio_capturer.Pass())); |
67 } | 67 } |
68 | 68 |
69 // static | 69 // static |
70 scoped_ptr<DesktopEnvironment> DesktopEnvironment::CreateFake( | 70 scoped_ptr<DesktopEnvironment> DesktopEnvironment::CreateFake( |
71 ChromotingHostContext* context, | 71 ChromotingHostContext* context, |
72 scoped_ptr<Capturer> capturer, | 72 scoped_ptr<VideoFrameCapturer> capturer, |
73 scoped_ptr<EventExecutor> event_executor, | 73 scoped_ptr<EventExecutor> event_executor, |
74 scoped_ptr<AudioCapturer> audio_capturer) { | 74 scoped_ptr<AudioCapturer> audio_capturer) { |
75 return scoped_ptr<DesktopEnvironment>( | 75 return scoped_ptr<DesktopEnvironment>( |
76 new DesktopEnvironment(context, | 76 new DesktopEnvironment(context, |
77 capturer.Pass(), | 77 capturer.Pass(), |
78 event_executor.Pass(), | 78 event_executor.Pass(), |
79 audio_capturer.Pass())); | 79 audio_capturer.Pass())); |
80 } | 80 } |
81 | 81 |
82 DesktopEnvironment::DesktopEnvironment( | 82 DesktopEnvironment::DesktopEnvironment( |
83 ChromotingHostContext* context, | 83 ChromotingHostContext* context, |
84 scoped_ptr<Capturer> capturer, | 84 scoped_ptr<VideoFrameCapturer> capturer, |
85 scoped_ptr<EventExecutor> event_executor, | 85 scoped_ptr<EventExecutor> event_executor, |
86 scoped_ptr<AudioCapturer> audio_capturer) | 86 scoped_ptr<AudioCapturer> audio_capturer) |
87 : context_(context), | 87 : context_(context), |
88 capturer_(capturer.Pass()), | 88 capturer_(capturer.Pass()), |
89 audio_capturer_(audio_capturer.Pass()), | 89 audio_capturer_(audio_capturer.Pass()), |
90 event_executor_(event_executor.Pass()) { | 90 event_executor_(event_executor.Pass()) { |
91 } | 91 } |
92 | 92 |
93 DesktopEnvironment::~DesktopEnvironment() { | 93 DesktopEnvironment::~DesktopEnvironment() { |
94 } | 94 } |
95 | 95 |
96 void DesktopEnvironment::OnSessionStarted( | 96 void DesktopEnvironment::OnSessionStarted( |
97 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 97 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
98 event_executor_->OnSessionStarted(client_clipboard.Pass()); | 98 event_executor_->OnSessionStarted(client_clipboard.Pass()); |
99 } | 99 } |
100 | 100 |
101 void DesktopEnvironment::OnSessionFinished() { | 101 void DesktopEnvironment::OnSessionFinished() { |
102 event_executor_->OnSessionFinished(); | 102 event_executor_->OnSessionFinished(); |
103 } | 103 } |
104 | 104 |
105 } // namespace remoting | 105 } // namespace remoting |
OLD | NEW |