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

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

Issue 2292723003: Move remaining Blimp feature code to core. (Closed)
Patch Set: Fixed gn check failure Created 4 years, 3 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
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/command_line.h"
Khushal 2016/08/31 04:30:47 Is the include needed?
David Trainor- moved to gerrit 2016/08/31 05:21:26 Oops meant to add it to the .cc file thanks
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.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 {
25 namespace client { 26 namespace client {
26 27
28 class BlimpCompositorDependencies;
27 class BlimpContentsManager; 29 class BlimpContentsManager;
30 class CompositorDependencies;
28 class ImeFeature; 31 class ImeFeature;
29 class NavigationFeature; 32 class NavigationFeature;
33 class RenderWidgetFeature;
34 class SettingsFeature;
30 class TabControlFeature; 35 class TabControlFeature;
31 36
32 // BlimpClientContextImpl is the implementation of the main context-class for 37 // BlimpClientContextImpl is the implementation of the main context-class for
33 // the blimp client. 38 // the blimp client.
34 class BlimpClientContextImpl : public BlimpClientContext, 39 class BlimpClientContextImpl : public BlimpClientContext,
35 public NetworkEventObserver { 40 public NetworkEventObserver {
36 public: 41 public:
37 // The |io_thread_task_runner| must be the task runner to use for IO 42 // The |io_thread_task_runner| must be the task runner to use for IO
38 // operations. 43 // operations.
39 // The |file_thread_task_runner| must be the task runner to use for file 44 // The |file_thread_task_runner| must be the task runner to use for file
40 // operations. 45 // operations.
41 BlimpClientContextImpl( 46 BlimpClientContextImpl(
42 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, 47 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
43 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner); 48 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
49 std::unique_ptr<CompositorDependencies> compositor_dependencies);
44 ~BlimpClientContextImpl() override; 50 ~BlimpClientContextImpl() override;
45 51
46 IdentitySource* GetIdentitySource(); 52 IdentitySource* GetIdentitySource();
47 53
48 // BlimpClientContext implementation. 54 // BlimpClientContext implementation.
49 void SetDelegate(BlimpClientContextDelegate* delegate) override; 55 void SetDelegate(BlimpClientContextDelegate* delegate) override;
50 std::unique_ptr<BlimpContents> CreateBlimpContents() override; 56 std::unique_ptr<BlimpContents> CreateBlimpContents() override;
51 void Connect() override; 57 void Connect() override;
52 58
53 // NetworkEventObserver implementation. 59 // NetworkEventObserver implementation.
54 void OnConnected() override; 60 void OnConnected() override;
55 void OnDisconnected(int result) override; 61 void OnDisconnected(int result) override;
56 62
57 TabControlFeature* GetTabControlFeature() const; 63 TabControlFeature* GetTabControlFeature() const;
58 64
59 protected: 65 protected:
60 // Returns the URL to use for connections to the assigner. Used to construct 66 // Returns the URL to use for connections to the assigner. Used to construct
61 // the AssignmentSource. 67 // the AssignmentSource.
62 virtual GURL GetAssignerURL(); 68 virtual GURL GetAssignerURL();
63 69
64 // Create IdentitySource which provides user sign in states and OAuth2 token
65 // service.
66 void CreateIdentitySource();
67
68 // Provide OAuth2 token and propagate account sign in states change.
69 std::unique_ptr<IdentitySource> identity_source_;
70
71 private: 70 private:
72 // Connect to assignment source with OAuth2 token to get an assignment. 71 // Connect to assignment source with OAuth2 token to get an assignment.
73 virtual void ConnectToAssignmentSource(const std::string& client_auth_token); 72 virtual void ConnectToAssignmentSource(const std::string& client_auth_token);
74 73
75 // The AssignmentCallback for when an assignment is ready. This will trigger 74 // The AssignmentCallback for when an assignment is ready. This will trigger
76 // a connection to the engine. 75 // a connection to the engine.
77 virtual void ConnectWithAssignment(AssignmentRequestResult result, 76 virtual void ConnectWithAssignment(AssignmentRequestResult result,
78 const Assignment& assignment); 77 const Assignment& assignment);
79 78
80 void RegisterFeatures(); 79 void RegisterFeatures();
80 void InitializeSettings();
81
82 // Create IdentitySource which provides user sign in states and OAuth2 token
83 // service.
84 void CreateIdentitySource();
81 85
82 // Provides functionality from the embedder. 86 // Provides functionality from the embedder.
83 BlimpClientContextDelegate* delegate_ = nullptr; 87 BlimpClientContextDelegate* delegate_ = nullptr;
84 88
85 // The task runner to use for IO operations. 89 // The task runner to use for IO operations.
86 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; 90 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
87 91
88 // The task runner to use for file operations. 92 // The task runner to use for file operations.
89 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; 93 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_;
90 94
91 // The AssignmentSource is used when the user of BlimpClientContextImpl calls 95 // The AssignmentSource is used when the user of BlimpClientContextImpl calls
92 // Connect() to get a valid assignment and later connect to the engine. 96 // Connect() to get a valid assignment and later connect to the engine.
93 std::unique_ptr<AssignmentSource> assignment_source_; 97 std::unique_ptr<AssignmentSource> assignment_source_;
94 98
99 // A set of dependencies required by all BlimpCompositor instances. The
100 // |delegate_| provides the embedder dependencies to this class when set.
Khushal 2016/08/31 04:30:47 We just get it in the ctor. Don't need to ask the
David Trainor- moved to gerrit 2016/08/31 05:21:26 Done.
101 std::unique_ptr<BlimpCompositorDependencies> blimp_compositor_dependencies_;
102
95 // Features to handle all incoming and outgoing protobuf messages. 103 // Features to handle all incoming and outgoing protobuf messages.
96 std::unique_ptr<ImeFeature> ime_feature_; 104 std::unique_ptr<ImeFeature> ime_feature_;
97 std::unique_ptr<NavigationFeature> navigation_feature_; 105 std::unique_ptr<NavigationFeature> navigation_feature_;
106 std::unique_ptr<RenderWidgetFeature> render_widget_feature_;
107 std::unique_ptr<SettingsFeature> settings_feature_;
98 std::unique_ptr<TabControlFeature> tab_control_feature_; 108 std::unique_ptr<TabControlFeature> tab_control_feature_;
99 109
100 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_; 110 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_;
101 111
102 // Container struct for network components. 112 // Container struct for network components.
103 // Must be deleted on the IO thread. 113 // Must be deleted on the IO thread.
104 std::unique_ptr<ClientNetworkComponents> net_components_; 114 std::unique_ptr<ClientNetworkComponents> net_components_;
105 115
106 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; 116 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_;
107 117
118 // Provide OAuth2 token and propagate account sign in states change.
119 std::unique_ptr<IdentitySource> identity_source_;
120
108 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_; 121 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_;
109 122
110 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl); 123 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl);
111 }; 124 };
112 125
113 } // namespace client 126 } // namespace client
114 } // namespace blimp 127 } // namespace blimp
115 128
116 #endif // BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_ 129 #endif // BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698