Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_ | 5 #ifndef BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_ |
| 6 #define BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_ | 6 #define BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "blimp/client/core/compositor/blob_image_serialization_processor.h" | |
| 15 #include "blimp/client/core/session/client_network_components.h" | 16 #include "blimp/client/core/session/client_network_components.h" |
| 16 #include "blimp/client/core/session/identity_source.h" | 17 #include "blimp/client/core/session/identity_source.h" |
| 17 #include "blimp/client/core/session/network_event_observer.h" | 18 #include "blimp/client/core/session/network_event_observer.h" |
| 18 #include "blimp/client/public/blimp_client_context.h" | 19 #include "blimp/client/public/blimp_client_context.h" |
| 19 #include "blimp/client/public/contents/blimp_contents.h" | 20 #include "blimp/client/public/contents/blimp_contents.h" |
| 20 #include "blimp/client/public/session/assignment.h" | 21 #include "blimp/client/public/session/assignment.h" |
| 21 #include "blimp/net/thread_pipe_manager.h" | 22 #include "blimp/net/thread_pipe_manager.h" |
| 22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 23 | 24 |
| 24 namespace blimp { | 25 namespace blimp { |
| 26 | |
| 27 class HeliumBlobReceiverDelegate; | |
| 28 | |
| 25 namespace client { | 29 namespace client { |
| 26 | 30 |
| 27 class BlimpContentsManager; | 31 class BlimpContentsManager; |
| 28 class ImeFeature; | 32 class ImeFeature; |
| 29 class NavigationFeature; | 33 class NavigationFeature; |
| 30 class TabControlFeature; | 34 class TabControlFeature; |
| 31 | 35 |
| 32 // BlimpClientContextImpl is the implementation of the main context-class for | 36 // BlimpClientContextImpl is the implementation of the main context-class for |
| 33 // the blimp client. | 37 // the blimp client. |
| 34 class BlimpClientContextImpl : public BlimpClientContext, | 38 class BlimpClientContextImpl |
| 35 public NetworkEventObserver { | 39 : public BlimpClientContext, |
| 40 public BlobImageSerializationProcessor::ErrorDelegate, | |
| 41 public NetworkEventObserver { | |
| 36 public: | 42 public: |
| 43 // Set ImageGenerator factory for Skia, can also be called by | |
| 44 // blimp_startup.cc in blimp/client/app. | |
| 45 static void SetImageGeneratorFromEncodedFactory(); | |
| 46 | |
| 37 // The |io_thread_task_runner| must be the task runner to use for IO | 47 // The |io_thread_task_runner| must be the task runner to use for IO |
| 38 // operations. | 48 // operations. |
| 39 // The |file_thread_task_runner| must be the task runner to use for file | 49 // The |file_thread_task_runner| must be the task runner to use for file |
| 40 // operations. | 50 // operations. |
| 41 BlimpClientContextImpl( | 51 BlimpClientContextImpl( |
| 42 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 52 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
| 43 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner); | 53 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner); |
| 44 ~BlimpClientContextImpl() override; | 54 ~BlimpClientContextImpl() override; |
| 45 | 55 |
| 46 IdentitySource* GetIdentitySource(); | 56 IdentitySource* GetIdentitySource(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 72 // Connect to assignment source with OAuth2 token to get an assignment. | 82 // Connect to assignment source with OAuth2 token to get an assignment. |
| 73 virtual void ConnectToAssignmentSource(const std::string& client_auth_token); | 83 virtual void ConnectToAssignmentSource(const std::string& client_auth_token); |
| 74 | 84 |
| 75 // The AssignmentCallback for when an assignment is ready. This will trigger | 85 // The AssignmentCallback for when an assignment is ready. This will trigger |
| 76 // a connection to the engine. | 86 // a connection to the engine. |
| 77 virtual void ConnectWithAssignment(AssignmentRequestResult result, | 87 virtual void ConnectWithAssignment(AssignmentRequestResult result, |
| 78 const Assignment& assignment); | 88 const Assignment& assignment); |
| 79 | 89 |
| 80 void RegisterFeatures(); | 90 void RegisterFeatures(); |
| 81 | 91 |
| 92 // Setup blob channel. | |
|
David Trainor- moved to gerrit
2016/08/31 05:40:57
I do this a lot too, but maybe just remove this co
xingliu
2016/09/01 02:08:10
Done.
| |
| 93 void SetupBlobChannel(); | |
| 94 | |
| 95 // BlobImageSerializationProcessor::ErrorDelegate implementation. | |
| 96 void OnImageDecodeError() override; | |
| 97 | |
| 82 // Provides functionality from the embedder. | 98 // Provides functionality from the embedder. |
| 83 BlimpClientContextDelegate* delegate_ = nullptr; | 99 BlimpClientContextDelegate* delegate_ = nullptr; |
| 84 | 100 |
| 85 // The task runner to use for IO operations. | 101 // The task runner to use for IO operations. |
| 86 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; | 102 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; |
| 87 | 103 |
| 88 // The task runner to use for file operations. | 104 // The task runner to use for file operations. |
| 89 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; | 105 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; |
| 90 | 106 |
| 91 // The AssignmentSource is used when the user of BlimpClientContextImpl calls | 107 // The AssignmentSource is used when the user of BlimpClientContextImpl calls |
| 92 // Connect() to get a valid assignment and later connect to the engine. | 108 // Connect() to get a valid assignment and later connect to the engine. |
| 93 std::unique_ptr<AssignmentSource> assignment_source_; | 109 std::unique_ptr<AssignmentSource> assignment_source_; |
| 94 | 110 |
| 95 // Features to handle all incoming and outgoing protobuf messages. | 111 // Features to handle all incoming and outgoing protobuf messages. |
| 96 std::unique_ptr<ImeFeature> ime_feature_; | 112 std::unique_ptr<ImeFeature> ime_feature_; |
| 97 std::unique_ptr<NavigationFeature> navigation_feature_; | 113 std::unique_ptr<NavigationFeature> navigation_feature_; |
| 98 std::unique_ptr<TabControlFeature> tab_control_feature_; | 114 std::unique_ptr<TabControlFeature> tab_control_feature_; |
| 99 | 115 |
| 100 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_; | 116 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_; |
| 101 | 117 |
| 102 // Container struct for network components. | 118 // Container struct for network components. |
| 103 // Must be deleted on the IO thread. | 119 // Must be deleted on the IO thread. |
| 104 std::unique_ptr<ClientNetworkComponents> net_components_; | 120 std::unique_ptr<ClientNetworkComponents> net_components_; |
| 105 | 121 |
| 106 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; | 122 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; |
| 107 | 123 |
| 124 // Receives blob BlimpMessages and relays them to BlobChannelReceiver. | |
| 125 // Owned by BlobChannelReceiver, therefore stored as a raw pointer here. | |
| 126 HeliumBlobReceiverDelegate* blob_delegate_ = nullptr; | |
| 127 | |
| 128 // Retrieves and decodes image data from |blob_receiver_|. Must outlive | |
| 129 // |blob_receiver_|. | |
| 130 BlobImageSerializationProcessor blob_image_processor_; | |
| 131 | |
| 132 std::unique_ptr<BlobChannelReceiver> blob_receiver_; | |
| 133 | |
| 108 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_; | 134 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_; |
| 109 | 135 |
| 110 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl); | 136 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl); |
| 111 }; | 137 }; |
| 112 | 138 |
| 113 } // namespace client | 139 } // namespace client |
| 114 } // namespace blimp | 140 } // namespace blimp |
| 115 | 141 |
| 116 #endif // BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_ | 142 #endif // BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_ |
| OLD | NEW |