| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_DISPLAY_CHROMEOS_APPLY_CONTENT_PROTECTION_TASK_H_ | |
| 6 #define UI_DISPLAY_CHROMEOS_APPLY_CONTENT_PROTECTION_TASK_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <stdint.h> | |
| 10 | |
| 11 #include <map> | |
| 12 #include <vector> | |
| 13 | |
| 14 #include "base/macros.h" | |
| 15 #include "base/memory/weak_ptr.h" | |
| 16 #include "ui/display/chromeos/display_configurator.h" | |
| 17 | |
| 18 namespace ui { | |
| 19 | |
| 20 class DisplayLayoutManager; | |
| 21 class NativeDisplayDelegate; | |
| 22 | |
| 23 // In order to apply content protection the task executes in the following | |
| 24 // manner: | |
| 25 // 1) Run() | |
| 26 // a) Query NativeDisplayDelegate for HDCP state on capable displays | |
| 27 // b) OnHDCPStateUpdate() called for each display as response to (a) | |
| 28 // 2) ApplyProtections() | |
| 29 // a) Compute preferred HDCP state for capable displays | |
| 30 // b) Call into NativeDisplayDelegate to set HDCP state on capable displays | |
| 31 // c) OnHDCPStateApplied() called for each display as reponse to (b) | |
| 32 // 3) Call |callback_| to signal end of task. | |
| 33 // | |
| 34 // Note, in steps 1a and 2a, if no HDCP capable displays are found or if errors | |
| 35 // are reported, the task finishes early and skips to step 3. | |
| 36 class DISPLAY_EXPORT ApplyContentProtectionTask { | |
| 37 public: | |
| 38 typedef base::Callback<void(bool)> ResponseCallback; | |
| 39 | |
| 40 ApplyContentProtectionTask( | |
| 41 DisplayLayoutManager* layout_manager, | |
| 42 NativeDisplayDelegate* native_display_delegate, | |
| 43 const DisplayConfigurator::ContentProtections& requests, | |
| 44 const ResponseCallback& callback); | |
| 45 ~ApplyContentProtectionTask(); | |
| 46 | |
| 47 void Run(); | |
| 48 | |
| 49 private: | |
| 50 // Callback to NatvieDisplayDelegate::GetHDCPState() | |
| 51 void OnHDCPStateUpdate(int64_t display_id, bool success, HDCPState state); | |
| 52 | |
| 53 // Callback to NativeDisplayDelegate::SetHDCPState() | |
| 54 void OnHDCPStateApplied(bool success); | |
| 55 | |
| 56 void ApplyProtections(); | |
| 57 | |
| 58 uint32_t GetDesiredProtectionMask(int64_t display_id) const; | |
| 59 | |
| 60 DisplayLayoutManager* layout_manager_; // Not owned. | |
| 61 | |
| 62 NativeDisplayDelegate* native_display_delegate_; // Not owned. | |
| 63 | |
| 64 DisplayConfigurator::ContentProtections requests_; | |
| 65 | |
| 66 // Callback used to respond once the task finishes. | |
| 67 ResponseCallback callback_; | |
| 68 | |
| 69 // Mapping between display IDs and the HDCP state returned by | |
| 70 // NativeDisplayDelegate. | |
| 71 std::map<int64_t, HDCPState> display_hdcp_state_map_; | |
| 72 | |
| 73 // Tracks the status of the NativeDisplayDelegate responses. This will be true | |
| 74 // if all the queries were successful, false otherwise. | |
| 75 bool query_status_; | |
| 76 | |
| 77 // Tracks the number of NativeDisplayDelegate requests sent but not answered | |
| 78 // yet. | |
| 79 size_t pending_requests_; | |
| 80 | |
| 81 base::WeakPtrFactory<ApplyContentProtectionTask> weak_ptr_factory_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(ApplyContentProtectionTask); | |
| 84 }; | |
| 85 | |
| 86 } // namespace ui | |
| 87 | |
| 88 #endif // UI_DISPLAY_CHROMEOS_APPLY_CONTENT_PROTECTION_TASK_H_ | |
| OLD | NEW |