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

Side by Side Diff: content/browser/wake_lock/wake_lock_browsertest.cc

Issue 2843353003: Move ownership of PowerSaveBlocker from WakeLockServiceContext to WakeLockServiceImpl (Closed)
Patch Set: code rebase Created 3 years, 7 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/test/test_timeouts.h" 6 #include "base/test/test_timeouts.h"
7 #include "content/browser/web_contents/web_contents_impl.h" 7 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/common/content_switches.h" 8 #include "content/public/common/content_switches.h"
9 #include "content/public/test/browser_test_utils.h" 9 #include "content/public/test/browser_test_utils.h"
10 #include "content/public/test/content_browser_test.h" 10 #include "content/public/test/content_browser_test.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 FrameTreeNode* GetNestedFrameNode() { 59 FrameTreeNode* GetNestedFrameNode() {
60 FrameTreeNode* root = GetWebContentsImpl()->GetFrameTree()->root(); 60 FrameTreeNode* root = GetWebContentsImpl()->GetFrameTree()->root();
61 CHECK_EQ(1U, root->child_count()); 61 CHECK_EQ(1U, root->child_count());
62 return root->child_at(0); 62 return root->child_at(0);
63 } 63 }
64 64
65 RenderFrameHost* GetNestedFrame() { 65 RenderFrameHost* GetNestedFrame() {
66 return GetNestedFrameNode()->current_frame_host(); 66 return GetNestedFrameNode()->current_frame_host();
67 } 67 }
68 68
69 device::mojom::WakeLockContext* GetWakeLockServiceContext() { 69 device::mojom::WakeLockService* GetRendererWakeLock() {
70 return GetWebContentsImpl()->GetWakeLockServiceContext(); 70 return GetWebContentsImpl()->GetRendererWakeLock();
71 } 71 }
72 72
73 bool HasWakeLock() { 73 bool HasWakeLock() {
74 bool has_wakelock = false; 74 bool has_wakelock = false;
75 base::RunLoop run_loop; 75 base::RunLoop run_loop;
76 76
77 GetWakeLockServiceContext()->HasWakeLockForTests( 77 GetRendererWakeLock()->HasWakeLockForTests(
78 base::Bind(&OnHasWakeLock, &has_wakelock)); 78 base::Bind(&OnHasWakeLock, &has_wakelock));
79 run_loop.Run(); 79 run_loop.Run();
80 return has_wakelock; 80 return has_wakelock;
81 } 81 }
82 82
83 void WaitForPossibleUpdate() { 83 void WaitForPossibleUpdate() {
84 // As Mojo channels have no common FIFO order in respect to each other and 84 // As Mojo channels have no common FIFO order in respect to each other and
85 // to the Chromium IPC, we cannot assume that when screen.keepAwake state 85 // to the Chromium IPC, we cannot assume that when screen.keepAwake state
86 // is changed from within a script, mojom::WakeLockService will receive an 86 // is changed from within a script, mojom::WakeLockService will receive an
87 // update request before ExecuteScript() returns. Therefore, some time slack 87 // update request before ExecuteScript() returns. Therefore, some time slack
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 GetNestedFrame()->GetProcess(), 377 GetNestedFrame()->GetProcess(),
378 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 378 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
379 GetNestedFrame()->GetProcess()->Shutdown(0, false); 379 GetNestedFrame()->GetProcess()->Shutdown(0, false);
380 watcher.Wait(); 380 watcher.Wait();
381 381
382 // Screen wake lock should be released. 382 // Screen wake lock should be released.
383 EXPECT_FALSE(HasWakeLock()); 383 EXPECT_FALSE(HasWakeLock());
384 } 384 }
385 385
386 } // namespace content 386 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698