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

Side by Side Diff: device/wake_lock/wake_lock_service_impl.h

Issue 2883903002: Add service unittest for WakeLockServiceImpl. (Closed)
Patch Set: Rename Fake* to *ForTesting Created 3 years, 6 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
« no previous file with comments | « device/wake_lock/wake_lock_provider.cc ('k') | device/wake_lock/wake_lock_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ 5 #ifndef DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_
6 #define DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ 6 #define DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 19 matching lines...) Expand all
30 WakeLockContextCallback native_view_getter, 30 WakeLockContextCallback native_view_getter,
31 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); 31 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
32 ~WakeLockServiceImpl() override; 32 ~WakeLockServiceImpl() override;
33 33
34 // WakeLockSevice implementation. 34 // WakeLockSevice implementation.
35 void RequestWakeLock() override; 35 void RequestWakeLock() override;
36 void CancelWakeLock() override; 36 void CancelWakeLock() override;
37 void AddClient(mojom::WakeLockServiceRequest request) override; 37 void AddClient(mojom::WakeLockServiceRequest request) override;
38 void HasWakeLockForTests(HasWakeLockForTestsCallback callback) override; 38 void HasWakeLockForTests(HasWakeLockForTestsCallback callback) override;
39 39
40 protected:
41 int num_lock_requests_;
42
40 private: 43 private:
41 void UpdateWakeLock(); 44 virtual void UpdateWakeLock();
42 void CreateWakeLock(); 45 virtual void CreateWakeLock();
43 void RemoveWakeLock(); 46 virtual void RemoveWakeLock();
47
44 void OnConnectionError(); 48 void OnConnectionError();
45 49
46 mojom::WakeLockType type_; 50 mojom::WakeLockType type_;
47 mojom::WakeLockReason reason_; 51 mojom::WakeLockReason reason_;
48 std::unique_ptr<std::string> description_; 52 std::unique_ptr<std::string> description_;
49 int num_lock_requests_;
50 53
51 #if defined(OS_ANDROID) 54 #if defined(OS_ANDROID)
52 int context_id_; 55 int context_id_;
53 WakeLockContextCallback native_view_getter_; 56 WakeLockContextCallback native_view_getter_;
54 #endif 57 #endif
55 58
56 scoped_refptr<base::SequencedTaskRunner> main_task_runner_; 59 scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
57 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 60 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
58 61
59 // The actual power save blocker for screen. 62 // The actual power save blocker for screen.
60 std::unique_ptr<PowerSaveBlocker> wake_lock_; 63 std::unique_ptr<PowerSaveBlocker> wake_lock_;
61 64
62 // Multiple clients that associate to the same WebContents share the same one 65 // Multiple clients that associate to the same WebContents share the same one
63 // WakeLockServiceImpl instance. Two consecutive |RequestWakeLock| requests 66 // WakeLockServiceImpl instance. Two consecutive |RequestWakeLock| requests
64 // from the same client should be coalesced as one request. Everytime a new 67 // from the same client should be coalesced as one request. Everytime a new
65 // client is being added into the BindingSet, we create an unique_ptr<bool> 68 // client is being added into the BindingSet, we create an unique_ptr<bool>
66 // as its context, which records this client's request status. 69 // as its context, which records this client's request status.
67 mojo::BindingSet<mojom::WakeLockService, std::unique_ptr<bool>> binding_set_; 70 mojo::BindingSet<mojom::WakeLockService, std::unique_ptr<bool>> binding_set_;
68 71
69 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceImpl); 72 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceImpl);
70 }; 73 };
71 74
72 } // namespace device 75 } // namespace device
73 76
74 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ 77 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « device/wake_lock/wake_lock_provider.cc ('k') | device/wake_lock/wake_lock_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698