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

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

Issue 2883903002: Add service unittest for WakeLockServiceImpl. (Closed)
Patch Set: Add FakeWakeLockServiceImpl. 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 #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 20 matching lines...) Expand all
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( 38 void HasWakeLockForTests(
39 const HasWakeLockForTestsCallback& callback) override; 39 const HasWakeLockForTestsCallback& callback) override;
40 40
41 protected:
42 int num_lock_requests_;
43
41 private: 44 private:
42 void UpdateWakeLock(); 45 virtual void UpdateWakeLock();
43 void CreateWakeLock(); 46 virtual void CreateWakeLock();
44 void RemoveWakeLock(); 47 virtual void RemoveWakeLock();
48
45 void OnConnectionError(); 49 void OnConnectionError();
46 50
47 mojom::WakeLockType type_; 51 mojom::WakeLockType type_;
48 mojom::WakeLockReason reason_; 52 mojom::WakeLockReason reason_;
49 std::unique_ptr<std::string> description_; 53 std::unique_ptr<std::string> description_;
50 int num_lock_requests_;
51 54
52 #if defined(OS_ANDROID) 55 #if defined(OS_ANDROID)
53 int context_id_; 56 int context_id_;
54 WakeLockContextCallback native_view_getter_; 57 WakeLockContextCallback native_view_getter_;
55 #endif 58 #endif
56 59
57 scoped_refptr<base::SequencedTaskRunner> main_task_runner_; 60 scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
58 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 61 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
59 62
60 // The actual power save blocker for screen. 63 // The actual power save blocker for screen.
61 std::unique_ptr<PowerSaveBlocker> wake_lock_; 64 std::unique_ptr<PowerSaveBlocker> wake_lock_;
62 65
63 // Multiple clients that associate to the same WebContents share the same one 66 // Multiple clients that associate to the same WebContents share the same one
64 // WakeLockServiceImpl instance. Two consecutive |RequestWakeLock| requests 67 // WakeLockServiceImpl instance. Two consecutive |RequestWakeLock| requests
65 // from the same client should be coalesced as one request. Everytime a new 68 // from the same client should be coalesced as one request. Everytime a new
66 // client is being added into the BindingSet, we create an unique_ptr<bool> 69 // client is being added into the BindingSet, we create an unique_ptr<bool>
67 // as its context, which records this client's request status. 70 // as its context, which records this client's request status.
68 mojo::BindingSet<mojom::WakeLockService, std::unique_ptr<bool>> binding_set_; 71 mojo::BindingSet<mojom::WakeLockService, std::unique_ptr<bool>> binding_set_;
69 72
70 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceImpl); 73 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceImpl);
71 }; 74 };
72 75
73 } // namespace device 76 } // namespace device
74 77
75 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_ 78 #endif // DEVICE_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698