OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/utility_process_host.h" | 9 #include "content/public/browser/utility_process_host.h" |
10 #include "content/public/browser/utility_process_host_client.h" | 10 #include "content/public/browser/utility_process_host_client.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 protected: | 32 protected: |
33 void RunUtilityProcessOnIOThread(bool elevated) { | 33 void RunUtilityProcessOnIOThread(bool elevated) { |
34 UtilityProcessHost* host = UtilityProcessHost::Create(nullptr, nullptr); | 34 UtilityProcessHost* host = UtilityProcessHost::Create(nullptr, nullptr); |
35 host->SetName(base::ASCIIToUTF16("TestProcess")); | 35 host->SetName(base::ASCIIToUTF16("TestProcess")); |
36 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
37 if (elevated) | 37 if (elevated) |
38 host->ElevatePrivileges(); | 38 host->ElevatePrivileges(); |
39 #endif | 39 #endif |
40 EXPECT_TRUE(host->Start()); | 40 EXPECT_TRUE(host->Start()); |
41 | 41 |
42 host->GetRemoteInterfaces()->GetInterface(&service_); | 42 BindInterface(host, &service_); |
43 service_->DoSomething(base::Bind( | 43 service_->DoSomething(base::Bind( |
44 &UtilityProcessHostImplBrowserTest::OnSomething, | 44 &UtilityProcessHostImplBrowserTest::OnSomething, |
45 base::Unretained(this))); | 45 base::Unretained(this))); |
46 } | 46 } |
47 | 47 |
48 void OnSomething() { | 48 void OnSomething() { |
49 service_.reset(); | 49 service_.reset(); |
50 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, done_closure_); | 50 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, done_closure_); |
51 } | 51 } |
52 | 52 |
53 mojom::TestServicePtr service_; | 53 mojom::TestServicePtr service_; |
54 base::Closure done_closure_; | 54 base::Closure done_closure_; |
55 }; | 55 }; |
56 | 56 |
57 IN_PROC_BROWSER_TEST_F(UtilityProcessHostImplBrowserTest, LaunchProcess) { | 57 IN_PROC_BROWSER_TEST_F(UtilityProcessHostImplBrowserTest, LaunchProcess) { |
58 RunUtilityProcess(false); | 58 RunUtilityProcess(false); |
59 } | 59 } |
60 | 60 |
61 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
62 IN_PROC_BROWSER_TEST_F(UtilityProcessHostImplBrowserTest, | 62 IN_PROC_BROWSER_TEST_F(UtilityProcessHostImplBrowserTest, |
63 LaunchElevatedProcess) { | 63 LaunchElevatedProcess) { |
64 RunUtilityProcess(true); | 64 RunUtilityProcess(true); |
65 } | 65 } |
66 #endif | 66 #endif |
67 | 67 |
68 } // namespace content | 68 } // namespace content |
OLD | NEW |