| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_QUEUE_MESSAGE_SWAP_PROMISE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_NAVIGATOR_CONNECT_CONTEXT_H_ |
| 6 #define CONTENT_RENDERER_QUEUE_MESSAGE_SWAP_PROMISE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_NAVIGATOR_CONNECT_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "cc/base/swap_promise.h" | |
| 11 | |
| 12 namespace IPC { | |
| 13 class SyncMessageFilter; | |
| 14 } | |
| 15 | 10 |
| 16 namespace content { | 11 namespace content { |
| 17 | 12 |
| 18 class FrameSwapMessageQueue; | 13 class NavigatorConnectServiceFactory; |
| 19 | 14 |
| 20 class QueueMessageSwapPromise : public cc::SwapPromise { | 15 // Use this class to register additional navigator.connect service factories. |
| 16 // One instance of this class exists per StoragePartition. |
| 17 // TODO(mek): Add API to this class so NavigatorConnectService implementations |
| 18 // can send messages back to the client. |
| 19 // TODO(mek): Add API so services can close a connection. |
| 20 class NavigatorConnectContext |
| 21 : public base::RefCountedThreadSafe<NavigatorConnectContext> { |
| 21 public: | 22 public: |
| 22 QueueMessageSwapPromise(scoped_refptr<IPC::SyncMessageFilter> message_sender, | 23 // Register a service factory. The most recently added factory that claims to |
| 23 scoped_refptr<FrameSwapMessageQueue> message_queue, | 24 // handle a URL will be used to handle a connection request for that URL. |
| 24 int source_frame_number); | 25 virtual void AddFactory( |
| 26 scoped_ptr<NavigatorConnectServiceFactory> factory) = 0; |
| 25 | 27 |
| 26 ~QueueMessageSwapPromise() override; | 28 protected: |
| 27 | 29 friend class base::RefCountedThreadSafe<NavigatorConnectContext>; |
| 28 void DidSwap(cc::CompositorFrameMetadata* metadata) override; | 30 NavigatorConnectContext() {} |
| 29 | 31 virtual ~NavigatorConnectContext() {} |
| 30 void DidNotSwap(DidNotSwapReason reason) override; | |
| 31 | |
| 32 int64 TraceId() const override; | |
| 33 | |
| 34 private: | |
| 35 void PromiseCompleted(); | |
| 36 | |
| 37 scoped_refptr<IPC::SyncMessageFilter> message_sender_; | |
| 38 scoped_refptr<content::FrameSwapMessageQueue> message_queue_; | |
| 39 int source_frame_number_; | |
| 40 #if DCHECK_IS_ON() | |
| 41 bool completed_; | |
| 42 #endif | |
| 43 }; | 32 }; |
| 44 | 33 |
| 45 } // namespace content | 34 } // namespace content |
| 46 | 35 |
| 47 #endif // CONTENT_RENDERER_QUEUE_MESSAGE_SWAP_PROMISE_H_ | 36 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATOR_CONNECT_CONTEXT_H_ |
| OLD | NEW |