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

Side by Side Diff: blimp/client/core/blimp_client_context_impl.h

Issue 2376573002: Cleanup blimp/client/core code organization. (Closed)
Patch Set: merged origin/master Created 4 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_
6 #define BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_
7
8 #include <memory>
9 #include <string>
10 #include <unordered_map>
11
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/single_thread_task_runner.h"
16 #include "base/threading/thread.h"
17 #include "blimp/client/core/compositor/blob_image_serialization_processor.h"
18 #include "blimp/client/core/session/client_network_components.h"
19 #include "blimp/client/core/session/connection_status.h"
20 #include "blimp/client/core/session/identity_source.h"
21 #include "blimp/client/core/settings/blimp_settings_delegate.h"
22 #include "blimp/client/public/blimp_client_context.h"
23 #include "blimp/client/public/contents/blimp_contents.h"
24 #include "blimp/client/public/session/assignment.h"
25 #include "blimp/net/thread_pipe_manager.h"
26 #include "url/gurl.h"
27
28 namespace blimp {
29 namespace client {
30
31 class BlimpCompositorDependencies;
32 class BlimpContentsManager;
33 class BlobChannelFeature;
34 class CompositorDependencies;
35 class GeolocationFeature;
36 class ImeFeature;
37 class NavigationFeature;
38 class RenderWidgetFeature;
39 class SettingsFeature;
40 class TabControlFeature;
41
42 // BlimpClientContextImpl is the implementation of the main context-class for
43 // the blimp client.
44 class BlimpClientContextImpl
45 : public BlimpClientContext,
46 public BlimpSettingsDelegate,
47 public BlobImageSerializationProcessor::ErrorDelegate {
48 public:
49 // The |io_thread_task_runner| must be the task runner to use for IO
50 // operations.
51 // The |file_thread_task_runner| must be the task runner to use for file
52 // operations.
53 BlimpClientContextImpl(
54 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
55 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
56 std::unique_ptr<CompositorDependencies> compositor_dependencies);
57 ~BlimpClientContextImpl() override;
58
59 // BlimpClientContext implementation.
60 void SetDelegate(BlimpClientContextDelegate* delegate) override;
61 std::unique_ptr<BlimpContents> CreateBlimpContents(
62 gfx::NativeWindow window) override;
63 void Connect() override;
64 void ConnectWithAssignment(const Assignment& assignment) override;
65
66 // Creates a data object containing data about Blimp to be used for feedback.
67 std::unordered_map<std::string, std::string> CreateFeedbackData();
68
69 protected:
70 // Returns the URL to use for connections to the assigner. Used to construct
71 // the AssignmentSource.
72 virtual GURL GetAssignerURL();
73
74 // BlimpSettingsDelegate implementation.
75 IdentitySource* GetIdentitySource() override;
76 ConnectionStatus* GetConnectionStatus() override;
77
78 private:
79 // Called when an OAuth2 token is received. Will then ask the
80 // AssignmentSource for an Assignment with this token.
81 virtual void OnAuthTokenReceived(const std::string& client_auth_token);
82
83 // Called when the AssignmentSource is finished getting an Assignment. Will
84 // then call |ConnectWithAssignment| to initiate the actual connection.
85 virtual void OnAssignmentReceived(AssignmentRequestResult result,
86 const Assignment& assignment);
87
88 void RegisterFeatures();
89 void InitializeSettings();
90
91 // Terminates the active connection held by |net_connections_|.
92 // May be called on any thread.
93 void DropConnection();
94
95 // Create IdentitySource which provides user sign in states and OAuth2 token
96 // service.
97 void CreateIdentitySource();
98
99 // BlobImageSerializationProcessor::ErrorDelegate implementation.
100 void OnImageDecodeError() override;
101
102 // Provides functionality from the embedder.
103 BlimpClientContextDelegate* delegate_ = nullptr;
104
105 // The task runner to use for IO operations.
106 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
107
108 // The task runner to use for file operations.
109 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_;
110
111 // The AssignmentSource is used when the user of BlimpClientContextImpl calls
112 // Connect() to get a valid assignment and later connect to the engine.
113 std::unique_ptr<AssignmentSource> assignment_source_;
114
115 // A set of dependencies required by all BlimpCompositor instances.
116 std::unique_ptr<BlimpCompositorDependencies> blimp_compositor_dependencies_;
117
118 // Features to handle all incoming and outgoing protobuf messages.
119 std::unique_ptr<BlobChannelFeature> blob_channel_feature_;
120 std::unique_ptr<GeolocationFeature> geolocation_feature_;
121 std::unique_ptr<ImeFeature> ime_feature_;
122 std::unique_ptr<NavigationFeature> navigation_feature_;
123 std::unique_ptr<RenderWidgetFeature> render_widget_feature_;
124 std::unique_ptr<SettingsFeature> settings_feature_;
125 std::unique_ptr<TabControlFeature> tab_control_feature_;
126
127 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_;
128
129 // Container struct for network components.
130 // Must be deleted on the IO thread.
131 std::unique_ptr<ClientNetworkComponents> net_components_;
132
133 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_;
134
135 // Provide OAuth2 token and propagate account sign in states change.
136 std::unique_ptr<IdentitySource> identity_source_;
137
138 // Connection status to the engine.
139 ConnectionStatus connection_status_;
140
141 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_;
142
143 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl);
144 };
145
146 } // namespace client
147 } // namespace blimp
148
149 #endif // BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698