Chromium Code Reviews| 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 BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ | 5 #ifndef BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ |
| 6 #define BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ | 6 #define BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 // BlimpClientSession represents a single active session of Blimp on the client | 35 // BlimpClientSession represents a single active session of Blimp on the client |
| 36 // regardless of whether or not the client application is in the background or | 36 // regardless of whether or not the client application is in the background or |
| 37 // foreground. The only time this session is invalid is during initialization | 37 // foreground. The only time this session is invalid is during initialization |
| 38 // and shutdown of this particular client process (or Activity on Android). | 38 // and shutdown of this particular client process (or Activity on Android). |
| 39 // | 39 // |
| 40 // This session glues together the feature proxy components and the network | 40 // This session glues together the feature proxy components and the network |
| 41 // layer. The network components must be interacted with on the IO thread. The | 41 // layer. The network components must be interacted with on the IO thread. The |
| 42 // feature proxies must be interacted with on the UI thread. | 42 // feature proxies must be interacted with on the UI thread. |
| 43 class BLIMP_CLIENT_EXPORT BlimpClientSession { | 43 class BLIMP_CLIENT_EXPORT BlimpClientSession { |
| 44 public: | 44 public: |
| 45 explicit BlimpClientSession(scoped_ptr<AssignmentSource> assignment_source); | 45 BlimpClientSession(); |
| 46 | 46 |
| 47 // Uses the AssignmentSource to get an Assignment and then uses the assignment | 47 // Uses the AssignmentSource to get an Assignment and then uses the assignment |
| 48 // configuration to connect to the Blimplet. | 48 // configuration to connect to the Blimplet. |
| 49 void Connect(); | 49 // |client_auth_token| is the login authentication token to use when querying |
| 50 // for an assignment. This token needs the OAuth2 scope of userinfo.email and | |
|
nyquist
2016/02/18 01:58:40
Could you mention that it only needs to be an acce
David Trainor- moved to gerrit
2016/02/18 16:01:55
Done.
| |
| 51 // should be signed by this APK. | |
|
nyquist
2016/02/18 01:58:40
An APK is an Android concept, and this code lives
David Trainor- moved to gerrit
2016/02/18 16:01:55
Good point! Removed.
| |
| 52 void Connect(const std::string& client_auth_token); | |
| 50 | 53 |
| 51 TabControlFeature* GetTabControlFeature() const; | 54 TabControlFeature* GetTabControlFeature() const; |
| 52 NavigationFeature* GetNavigationFeature() const; | 55 NavigationFeature* GetNavigationFeature() const; |
| 53 RenderWidgetFeature* GetRenderWidgetFeature() const; | 56 RenderWidgetFeature* GetRenderWidgetFeature() const; |
| 54 | 57 |
| 58 // The AssignmentCallback for when an assignment is ready. This will trigger | |
| 59 // a connection to the engine. | |
| 60 virtual void ConnectWithAssignment(AssignmentSource::Result result, | |
| 61 const Assignment& assignment); | |
| 62 | |
| 55 protected: | 63 protected: |
| 56 virtual ~BlimpClientSession(); | 64 virtual ~BlimpClientSession(); |
| 57 | 65 |
| 66 // Notified every time the AssignmentSource returns the result of an attempted | |
| 67 // assignment request. | |
| 68 virtual void OnAssignmentConnectionAttempted(AssignmentSource::Result result); | |
| 69 | |
| 58 private: | 70 private: |
| 59 // Registers a message processor which will receive all messages of the |type| | 71 // Registers a message processor which will receive all messages of the |type| |
| 60 // specified. Returns a BlimpMessageProcessor object for sending messages of | 72 // specified. Returns a BlimpMessageProcessor object for sending messages of |
| 61 // type |type|. | 73 // type |type|. |
| 62 scoped_ptr<BlimpMessageProcessor> RegisterFeature( | 74 scoped_ptr<BlimpMessageProcessor> RegisterFeature( |
| 63 BlimpMessage::Type type, | 75 BlimpMessage::Type type, |
| 64 BlimpMessageProcessor* incoming_processor); | 76 BlimpMessageProcessor* incoming_processor); |
| 65 | 77 |
| 66 // The AssignmentCallback for when an assignment is ready. This will trigger | |
| 67 // a connection to the engine. | |
| 68 void ConnectWithAssignment(const Assignment& assignment); | |
| 69 | |
| 70 // The AssignmentSource is used when the user of BlimpClientSession calls | |
| 71 // Connect() to get a valid assignment and later connect to the engine. | |
| 72 scoped_ptr<AssignmentSource> assignment_source_; | |
| 73 | |
| 74 base::Thread io_thread_; | 78 base::Thread io_thread_; |
| 75 scoped_ptr<TabControlFeature> tab_control_feature_; | 79 scoped_ptr<TabControlFeature> tab_control_feature_; |
| 76 scoped_ptr<NavigationFeature> navigation_feature_; | 80 scoped_ptr<NavigationFeature> navigation_feature_; |
| 77 scoped_ptr<RenderWidgetFeature> render_widget_feature_; | 81 scoped_ptr<RenderWidgetFeature> render_widget_feature_; |
| 78 | 82 |
| 83 // The AssignmentSource is used when the user of BlimpClientSession calls | |
| 84 // Connect() to get a valid assignment and later connect to the engine. | |
| 85 scoped_ptr<AssignmentSource> assignment_source_; | |
| 86 | |
| 79 // Container struct for network components. | 87 // Container struct for network components. |
| 80 // Must be deleted on the IO thread. | 88 // Must be deleted on the IO thread. |
| 81 scoped_ptr<ClientNetworkComponents> net_components_; | 89 scoped_ptr<ClientNetworkComponents> net_components_; |
| 82 | 90 |
| 83 // Pipes for receiving BlimpMessages from IO thread. | 91 // Pipes for receiving BlimpMessages from IO thread. |
| 84 // Incoming messages are only routed to the UI thread since all features run | 92 // Incoming messages are only routed to the UI thread since all features run |
| 85 // on the UI thread. | 93 // on the UI thread. |
| 86 std::vector<scoped_ptr<BlimpMessageThreadPipe>> incoming_pipes_; | 94 std::vector<scoped_ptr<BlimpMessageThreadPipe>> incoming_pipes_; |
| 87 | 95 |
| 88 base::WeakPtrFactory<BlimpClientSession> weak_factory_; | 96 base::WeakPtrFactory<BlimpClientSession> weak_factory_; |
| 89 | 97 |
| 90 DISALLOW_COPY_AND_ASSIGN(BlimpClientSession); | 98 DISALLOW_COPY_AND_ASSIGN(BlimpClientSession); |
| 91 }; | 99 }; |
| 92 | 100 |
| 93 } // namespace client | 101 } // namespace client |
| 94 } // namespace blimp | 102 } // namespace blimp |
| 95 | 103 |
| 96 #endif // BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ | 104 #endif // BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ |
| OLD | NEW |