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

Side by Side Diff: webrtc/modules/desktop_capture/win/desktop.cc

Issue 2787263003: Delete all log messages depending on system_wrappers. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/desktop_capture/win/desktop.h" 11 #include "webrtc/modules/desktop_capture/win/desktop.h"
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "webrtc/system_wrappers/include/logging.h"
16
17 namespace webrtc { 15 namespace webrtc {
18 16
19 Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) { 17 Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) {
20 } 18 }
21 19
22 Desktop::~Desktop() { 20 Desktop::~Desktop() {
23 if (own_ && desktop_ != NULL) { 21 if (own_ && desktop_ != NULL) {
24 if (!::CloseDesktop(desktop_)) { 22 if (!::CloseDesktop(desktop_)) {
25 LOG(LS_ERROR) << "Failed to close the owned desktop handle: "
26 << GetLastError();
27 } 23 }
28 } 24 }
29 } 25 }
30 26
31 bool Desktop::GetName(std::wstring* desktop_name_out) const { 27 bool Desktop::GetName(std::wstring* desktop_name_out) const {
32 if (desktop_ == NULL) 28 if (desktop_ == NULL)
33 return false; 29 return false;
34 30
35 DWORD length = 0; 31 DWORD length = 0;
36 int rv = GetUserObjectInformationW(desktop_, UOI_NAME, NULL, 0, &length); 32 int rv = GetUserObjectInformationW(desktop_, UOI_NAME, NULL, 0, &length);
37 if (rv || GetLastError() != ERROR_INSUFFICIENT_BUFFER) 33 if (rv || GetLastError() != ERROR_INSUFFICIENT_BUFFER)
38 abort(); 34 abort();
39 35
40 length /= sizeof(WCHAR); 36 length /= sizeof(WCHAR);
41 std::vector<WCHAR> buffer(length); 37 std::vector<WCHAR> buffer(length);
42 if (!GetUserObjectInformationW(desktop_, UOI_NAME, &buffer[0], 38 if (!GetUserObjectInformationW(desktop_, UOI_NAME, &buffer[0],
43 length * sizeof(WCHAR), &length)) { 39 length * sizeof(WCHAR), &length)) {
44 LOG(LS_ERROR) << "Failed to query the desktop name: " << GetLastError();
45 return false; 40 return false;
46 } 41 }
47 42
48 desktop_name_out->assign(&buffer[0], length / sizeof(WCHAR)); 43 desktop_name_out->assign(&buffer[0], length / sizeof(WCHAR));
49 return true; 44 return true;
50 } 45 }
51 46
52 bool Desktop::IsSame(const Desktop& other) const { 47 bool Desktop::IsSame(const Desktop& other) const {
53 std::wstring name; 48 std::wstring name;
54 if (!GetName(&name)) 49 if (!GetName(&name))
55 return false; 50 return false;
56 51
57 std::wstring other_name; 52 std::wstring other_name;
58 if (!other.GetName(&other_name)) 53 if (!other.GetName(&other_name))
59 return false; 54 return false;
60 55
61 return name == other_name; 56 return name == other_name;
62 } 57 }
63 58
64 bool Desktop::SetThreadDesktop() const { 59 bool Desktop::SetThreadDesktop() const {
65 if (!::SetThreadDesktop(desktop_)) { 60 if (!::SetThreadDesktop(desktop_)) {
66 LOG(LS_ERROR) << "Failed to assign the desktop to the current thread: "
67 << GetLastError();
68 return false; 61 return false;
69 } 62 }
70 63
71 return true; 64 return true;
72 } 65 }
73 66
74 Desktop* Desktop::GetDesktop(const WCHAR* desktop_name) { 67 Desktop* Desktop::GetDesktop(const WCHAR* desktop_name) {
75 ACCESS_MASK desired_access = 68 ACCESS_MASK desired_access =
76 DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE | 69 DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE |
77 DESKTOP_HOOKCONTROL | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS | 70 DESKTOP_HOOKCONTROL | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
78 DESKTOP_SWITCHDESKTOP | GENERIC_WRITE; 71 DESKTOP_SWITCHDESKTOP | GENERIC_WRITE;
79 HDESK desktop = OpenDesktop(desktop_name, 0, FALSE, desired_access); 72 HDESK desktop = OpenDesktop(desktop_name, 0, FALSE, desired_access);
80 if (desktop == NULL) { 73 if (desktop == NULL) {
81 LOG(LS_ERROR) << "Failed to open the desktop '" << desktop_name << "': "
82 << GetLastError();
83 return NULL; 74 return NULL;
84 } 75 }
85 76
86 return new Desktop(desktop, true); 77 return new Desktop(desktop, true);
87 } 78 }
88 79
89 Desktop* Desktop::GetInputDesktop() { 80 Desktop* Desktop::GetInputDesktop() {
90 HDESK desktop = OpenInputDesktop( 81 HDESK desktop = OpenInputDesktop(
91 0, FALSE, GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); 82 0, FALSE, GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE);
92 if (desktop == NULL) 83 if (desktop == NULL)
93 return NULL; 84 return NULL;
94 85
95 return new Desktop(desktop, true); 86 return new Desktop(desktop, true);
96 } 87 }
97 88
98 Desktop* Desktop::GetThreadDesktop() { 89 Desktop* Desktop::GetThreadDesktop() {
99 HDESK desktop = ::GetThreadDesktop(GetCurrentThreadId()); 90 HDESK desktop = ::GetThreadDesktop(GetCurrentThreadId());
100 if (desktop == NULL) { 91 if (desktop == NULL) {
101 LOG(LS_ERROR) << "Failed to retrieve the handle of the desktop assigned to "
102 "the current thread: "
103 << GetLastError();
104 return NULL; 92 return NULL;
105 } 93 }
106 94
107 return new Desktop(desktop, false); 95 return new Desktop(desktop, false);
108 } 96 }
109 97
110 } // namespace webrtc 98 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/desktop_capture/win/d3d_device.cc ('k') | webrtc/modules/desktop_capture/win/dxgi_texture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698