OLD | NEW |
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 CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
| 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/scoped_vector.h" |
16 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
17 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
18 #include "content/common/presentation/presentation_service.mojom.h" | 20 #include "content/common/presentation/presentation_service.mojom.h" |
19 #include "content/public/browser/navigation_details.h" | 21 #include "content/public/browser/navigation_details.h" |
20 #include "content/public/browser/presentation_screen_availability_listener.h" | 22 #include "content/public/browser/presentation_screen_availability_listener.h" |
21 #include "content/public/browser/presentation_service_delegate.h" | 23 #include "content/public/browser/presentation_service_delegate.h" |
22 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
23 #include "content/public/common/frame_navigate_params.h" | 25 #include "content/public/common/frame_navigate_params.h" |
24 | 26 |
25 namespace content { | 27 namespace content { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 const std::string& presentation_url); | 78 const std::string& presentation_url); |
77 ~ScreenAvailabilityContext() override; | 79 ~ScreenAvailabilityContext() override; |
78 | 80 |
79 // If available bit exists, |callback| will be invoked with the bit and | 81 // If available bit exists, |callback| will be invoked with the bit and |
80 // this state machine will reset. | 82 // this state machine will reset. |
81 // Otherwise |callback| is saved for later use. | 83 // Otherwise |callback| is saved for later use. |
82 // |callback|: Callback to the client of PresentationService | 84 // |callback|: Callback to the client of PresentationService |
83 // (i.e. the renderer) that screen availability has changed, via Mojo. | 85 // (i.e. the renderer) that screen availability has changed, via Mojo. |
84 void CallbackReceived(const ScreenAvailabilityMojoCallback& callback); | 86 void CallbackReceived(const ScreenAvailabilityMojoCallback& callback); |
85 | 87 |
86 // Clears both callback and available bit. | |
87 void Reset(); | |
88 | |
89 // PresentationScreenAvailabilityListener implementation. | 88 // PresentationScreenAvailabilityListener implementation. |
90 std::string GetPresentationUrl() const override; | 89 std::string GetPresentationUrl() const override; |
91 | 90 |
92 // If callback exists, it will be invoked with |available| and | 91 // If callback exists, it will be invoked with |available| and |
93 // this state machine will reset. | 92 // this state machine will reset. |
94 // Otherwise |available| is saved for later use. | 93 // Otherwise |available| is saved for later use. |
95 // |available|: New screen availability for the presentation URL. | 94 // |available|: New screen availability for the presentation URL. |
96 void OnScreenAvailabilityChanged(bool available) override; | 95 void OnScreenAvailabilityChanged(bool available) override; |
97 | 96 |
98 // Gets the callback as a raw pointer. | 97 // Pass this context's queued callbacks to another context. |
99 ScreenAvailabilityMojoCallback* GetCallback() const; | 98 void PassPendingCallbacks(ScreenAvailabilityContext* other); |
| 99 |
| 100 // Indicates if this context has any pending callbacks. |
| 101 bool HasPendingCallbacks() const; |
100 | 102 |
101 private: | 103 private: |
102 std::string presentation_url_; | 104 std::string presentation_url_; |
103 scoped_ptr<ScreenAvailabilityMojoCallback> callback_ptr_; | 105 ScopedVector<ScreenAvailabilityMojoCallback> callbacks_; |
104 scoped_ptr<bool> available_ptr_; | 106 scoped_ptr<bool> available_ptr_; |
105 }; | 107 }; |
106 | 108 |
107 // Context for a StartSession request. | 109 // Context for a StartSession request. |
108 struct CONTENT_EXPORT StartSessionRequest { | 110 struct CONTENT_EXPORT StartSessionRequest { |
109 StartSessionRequest(const std::string& presentation_url, | 111 StartSessionRequest(const std::string& presentation_url, |
110 const std::string& presentation_id, | 112 const std::string& presentation_id, |
111 const NewSessionMojoCallback& callback); | 113 const NewSessionMojoCallback& callback); |
112 ~StartSessionRequest(); | 114 ~StartSessionRequest(); |
113 | 115 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 234 |
233 // NOTE: Weak pointers must be invalidated before all other member variables. | 235 // NOTE: Weak pointers must be invalidated before all other member variables. |
234 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 236 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
235 | 237 |
236 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 238 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
237 }; | 239 }; |
238 | 240 |
239 } // namespace content | 241 } // namespace content |
240 | 242 |
241 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 243 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
OLD | NEW |