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

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

Issue 2211613002: Add AssignmentSource to BlimpClientContextImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge origin/master Created 4 years, 4 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/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/session/client_network_components.h" 15 #include "blimp/client/core/session/client_network_components.h"
16 #include "blimp/client/core/session/network_event_observer.h" 16 #include "blimp/client/core/session/network_event_observer.h"
17 #include "blimp/client/public/blimp_client_context.h" 17 #include "blimp/client/public/blimp_client_context.h"
18 #include "blimp/client/public/contents/blimp_contents.h" 18 #include "blimp/client/public/contents/blimp_contents.h"
19 #include "blimp/client/public/session/assignment.h"
19 #include "blimp/net/blimp_connection_statistics.h" 20 #include "blimp/net/blimp_connection_statistics.h"
20 #include "blimp/net/thread_pipe_manager.h" 21 #include "blimp/net/thread_pipe_manager.h"
22 #include "url/gurl.h"
21 23
22 namespace blimp { 24 namespace blimp {
23 namespace client { 25 namespace client {
24 26
25 class BlimpContentsManager; 27 class BlimpContentsManager;
26 28
27 // BlimpClientContextImpl is the implementation of the main context-class for 29 // BlimpClientContextImpl is the implementation of the main context-class for
28 // the blimp client. 30 // the blimp client.
29 class BlimpClientContextImpl : public BlimpClientContext, 31 class BlimpClientContextImpl : public BlimpClientContext,
30 public NetworkEventObserver { 32 public NetworkEventObserver {
31 public: 33 public:
32 // The |io_thread_task_runner| must be the task runner to use for IO 34 // The |io_thread_task_runner| must be the task runner to use for IO
33 // operations. 35 // operations.
34 explicit BlimpClientContextImpl( 36 // The |file_thread_task_runner| must be the task runner to use for file
35 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner); 37 // operations.
38 BlimpClientContextImpl(
39 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
40 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner);
36 ~BlimpClientContextImpl() override; 41 ~BlimpClientContextImpl() override;
37 42
38 // BlimpClientContext implementation. 43 // BlimpClientContext implementation.
39 void SetDelegate(BlimpClientContextDelegate* delegate) override; 44 void SetDelegate(BlimpClientContextDelegate* delegate) override;
40 std::unique_ptr<BlimpContents> CreateBlimpContents() override; 45 std::unique_ptr<BlimpContents> CreateBlimpContents() override;
46 void Connect(const std::string& client_auth_token) override;
41 47
42 // NetworkEventObserver implementation. 48 // NetworkEventObserver implementation.
43 void OnConnected() override; 49 void OnConnected() override;
44 void OnDisconnected(int result) override; 50 void OnDisconnected(int result) override;
45 51
52 protected:
53 // Returns the URL to use for connections to the assigner. Used to construct
54 // the AssignmentSource.
55 virtual GURL GetAssignerURL();
56
46 private: 57 private:
58 // The AssignmentCallback for when an assignment is ready. This will trigger
59 // a connection to the engine.
60 virtual void ConnectWithAssignment(AssignmentRequestResult result,
61 const Assignment& assignment);
62
47 // Provides functionality from the embedder. 63 // Provides functionality from the embedder.
48 BlimpClientContextDelegate* delegate_; 64 BlimpClientContextDelegate* delegate_ = nullptr;
49 65
50 // The task runner to use for IO operations. 66 // The task runner to use for IO operations.
51 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; 67 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
52 68
69 // The task runner to use for file operations.
70 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_;
71
72 // The AssignmentSource is used when the user of BlimpClientContextImpl calls
73 // Connect() to get a valid assignment and later connect to the engine.
74 std::unique_ptr<AssignmentSource> assignment_source_;
75
53 // Collects details of network, such as number of commits and bytes 76 // Collects details of network, such as number of commits and bytes
54 // transferred over network. Owned by ClientNetworkComponents. 77 // transferred over network. Owned by ClientNetworkComponents.
55 BlimpConnectionStatistics* blimp_connection_statistics_; 78 BlimpConnectionStatistics* blimp_connection_statistics_;
56 79
57 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_; 80 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_;
58 81
59 // Container struct for network components. 82 // Container struct for network components.
60 // Must be deleted on the IO thread. 83 // Must be deleted on the IO thread.
61 std::unique_ptr<ClientNetworkComponents> net_components_; 84 std::unique_ptr<ClientNetworkComponents> net_components_;
62 85
63 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; 86 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_;
64 87
65 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_; 88 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_;
66 89
67 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl); 90 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl);
68 }; 91 };
69 92
70 } // namespace client 93 } // namespace client
71 } // namespace blimp 94 } // namespace blimp
72 95
73 #endif // BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_ 96 #endif // BLIMP_CLIENT_CORE_BLIMP_CLIENT_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698