OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_VIDEO_CAPTURE_SCREEN_WIN_SCOPED_THREAD_DESKTOP_H_ | |
6 #define MEDIA_VIDEO_CAPTURE_SCREEN_WIN_SCOPED_THREAD_DESKTOP_H_ | |
7 | |
8 #include <windows.h> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "media/base/media_export.h" | |
13 | |
14 namespace media { | |
15 | |
16 class Desktop; | |
17 | |
18 class MEDIA_EXPORT ScopedThreadDesktop { | |
19 public: | |
20 ScopedThreadDesktop(); | |
21 ~ScopedThreadDesktop(); | |
22 | |
23 // Returns true if |desktop| has the same desktop name as the currently | |
24 // assigned desktop (if assigned) or as the initial desktop (if not assigned). | |
25 // Returns false in any other case including failing Win32 APIs and | |
26 // uninitialized desktop handles. | |
27 bool IsSame(const Desktop& desktop); | |
28 | |
29 // Reverts the calling thread to use the initial desktop. | |
30 void Revert(); | |
31 | |
32 // Assigns |desktop| to be the calling thread. Returns true if the thread has | |
33 // been switched to |desktop| successfully. | |
34 bool SetThreadDesktop(scoped_ptr<Desktop> desktop); | |
35 | |
36 private: | |
37 // The desktop handle assigned to the calling thread by Set | |
38 scoped_ptr<Desktop> assigned_; | |
39 | |
40 // The desktop handle assigned to the calling thread at creation. | |
41 scoped_ptr<Desktop> initial_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(ScopedThreadDesktop); | |
44 }; | |
45 | |
46 } // namespace media | |
47 | |
48 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_WIN_SCOPED_THREAD_DESKTOP_H_ | |
OLD | NEW |