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

Side by Side Diff: chrome_frame/test_utils.cc

Issue 71013004: Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add constructor Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 "chrome_frame/test_utils.h" 5 #include "chrome_frame/test_utils.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlwin.h> 8 #include <atlwin.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 "DllUnregisterUserServer", 81 "DllUnregisterUserServer",
82 }; 82 };
83 83
84 DCHECK(!path.empty()); 84 DCHECK(!path.empty());
85 DCHECK(registration_type == PER_USER || registration_type == SYSTEM_LEVEL); 85 DCHECK(registration_type == PER_USER || registration_type == SYSTEM_LEVEL);
86 DCHECK(registration_operation == REGISTER || 86 DCHECK(registration_operation == REGISTER ||
87 registration_operation == UNREGISTER); 87 registration_operation == UNREGISTER);
88 88
89 int entrypoint_index = 0; 89 int entrypoint_index = 0;
90 base::LaunchOptions launch_options; 90 base::LaunchOptions launch_options;
91 base::ProcessHandle process_handle = INVALID_HANDLE_VALUE; 91 base::win::ScopedHandle process_handle;
92 int exit_code = -1; 92 int exit_code = -1;
93 93
94 if (registration_type == PER_USER) 94 if (registration_type == PER_USER)
95 entrypoint_index += 2; 95 entrypoint_index += 2;
96 if (registration_operation == UNREGISTER) 96 if (registration_operation == UNREGISTER)
97 entrypoint_index += 1; 97 entrypoint_index += 1;
98 string16 registration_command(ASCIIToUTF16("\"")); 98 string16 registration_command(ASCIIToUTF16("\""));
99 registration_command += 99 registration_command +=
100 CommandLine::ForCurrentProcess()->GetProgram().value(); 100 CommandLine::ForCurrentProcess()->GetProgram().value();
101 registration_command += ASCIIToUTF16("\" "); 101 registration_command += ASCIIToUTF16("\" ");
102 registration_command += kCallRegistrationEntrypointSwitch; 102 registration_command += kCallRegistrationEntrypointSwitch;
103 registration_command += ASCIIToUTF16(" \""); 103 registration_command += ASCIIToUTF16(" \"");
104 registration_command += path; 104 registration_command += path;
105 registration_command += ASCIIToUTF16("\" "); 105 registration_command += ASCIIToUTF16("\" ");
106 registration_command += ASCIIToUTF16(kEntrypoints[entrypoint_index]); 106 registration_command += ASCIIToUTF16(kEntrypoints[entrypoint_index]);
107 launch_options.wait = true; 107 launch_options.wait = true;
108 if (!base::LaunchProcess(registration_command, launch_options, 108 if (!base::LaunchProcess(registration_command, launch_options,
109 &process_handle)) { 109 &process_handle)) {
110 PLOG(FATAL) 110 PLOG(FATAL)
111 << "Failed to register or unregister DLL with command: " 111 << "Failed to register or unregister DLL with command: "
112 << registration_command; 112 << registration_command;
113 } else { 113 } else {
114 base::win::ScopedHandle rundll32(process_handle); 114 base::win::ScopedHandle rundll32(process_handle.Get());
115 if (!base::WaitForExitCodeWithTimeout( 115 if (!base::WaitForExitCodeWithTimeout(
116 process_handle, &exit_code, 116 process_handle.Get(), &exit_code,
117 base::TimeDelta::FromMilliseconds(kDllRegistrationTimeoutMs))) { 117 base::TimeDelta::FromMilliseconds(kDllRegistrationTimeoutMs))) {
118 LOG(ERROR) << "Timeout waiting to register or unregister DLL with " 118 LOG(ERROR) << "Timeout waiting to register or unregister DLL with "
119 "command: " << registration_command; 119 "command: " << registration_command;
120 base::KillProcess(process_handle, 0, false); 120 base::KillProcess(process_handle.Get(), 0, false);
121 NOTREACHED() << "Aborting test due to registration failure."; 121 NOTREACHED() << "Aborting test due to registration failure.";
122 } 122 }
123 } 123 }
124 if (exit_code != 0) { 124 if (exit_code != 0) {
125 if (registration_operation == REGISTER) { 125 if (registration_operation == REGISTER) {
126 LOG(ERROR) 126 LOG(ERROR)
127 << "DLL registration failed (exit code: 0x" << std::hex << exit_code 127 << "DLL registration failed (exit code: 0x" << std::hex << exit_code
128 << ", command: " << registration_command 128 << ", command: " << registration_command
129 << "). Make sure you are running as Admin."; 129 << "). Make sure you are running as Admin.";
130 ::ExitProcess(1); 130 ::ExitProcess(1);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 UOI_NAME, 278 UOI_NAME,
279 name, 279 name,
280 sizeof(name), 280 sizeof(name),
281 &needed)) { 281 &needed)) {
282 is_locked = lstrcmpi(name, L"default") != 0; 282 is_locked = lstrcmpi(name, L"default") != 0;
283 } 283 }
284 ::CloseDesktop(input_desk); 284 ::CloseDesktop(input_desk);
285 } 285 }
286 return is_locked; 286 return is_locked;
287 } 287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698