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

Side by Side Diff: blimp/engine/browser_tests/blimp_client_session.cc

Issue 2620213004: Remove all blimp browsertests. (Closed)
Patch Set: Created 3 years, 11 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 2015 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 #include "blimp/engine/browser_tests/blimp_client_session.h"
6
7 #include <utility>
8 #include <vector>
9
10 #include "base/bind.h"
11 #include "base/command_line.h"
12 #include "base/location.h"
13 #include "base/logging.h"
14 #include "base/memory/ptr_util.h"
15 #include "base/sequenced_task_runner.h"
16 #include "base/task_runner_util.h"
17 #include "base/threading/sequenced_task_runner_handle.h"
18 #include "base/threading/thread.h"
19 #include "base/threading/thread_task_runner_handle.h"
20 #include "blimp/client/core/contents/ime_feature.h"
21 #include "blimp/client/core/contents/navigation_feature.h"
22 #include "blimp/client/core/contents/tab_control_feature.h"
23 #include "blimp/client/core/geolocation/geolocation_feature.h"
24 #include "blimp/client/core/render_widget/render_widget_feature.h"
25 #include "blimp/client/core/session/client_network_components.h"
26 #include "blimp/client/core/session/cross_thread_network_event_observer.h"
27 #include "blimp/client/core/switches/blimp_client_switches.h"
28 #include "blimp/common/blob_cache/in_memory_blob_cache.h"
29 #include "blimp/net/blimp_message_thread_pipe.h"
30 #include "blimp/net/blimp_stats.h"
31 #include "blimp/net/blob_channel/blob_channel_receiver.h"
32 #include "blimp/net/blob_channel/helium_blob_receiver_delegate.h"
33 #include "blimp/net/thread_pipe_manager.h"
34 #include "device/geolocation/geolocation_delegate.h"
35 #include "device/geolocation/location_arbitrator.h"
36 #include "url/gurl.h"
37
38 namespace blimp {
39 namespace client {
40 namespace {
41
42 void DropConnectionOnIOThread(ClientNetworkComponents* net_components) {
43 net_components->GetBrowserConnectionHandler()->DropCurrentConnection();
44 }
45
46 } // namespace
47
48 BlimpClientSession::BlimpClientSession(const GURL& assigner_endpoint)
49 : io_thread_("BlimpIOThread"),
50 geolocation_feature_(base::MakeUnique<GeolocationFeature>(
51 base::MakeUnique<device::LocationArbitrator>(
52 base::MakeUnique<device::GeolocationDelegate>()))),
53 tab_control_feature_(new TabControlFeature),
54 navigation_feature_(new NavigationFeature),
55 ime_feature_(new ImeFeature),
56 render_widget_feature_(new RenderWidgetFeature),
57 weak_factory_(this) {
58 base::Thread::Options options;
59 options.message_loop_type = base::MessageLoop::TYPE_IO;
60 io_thread_.StartWithOptions(options);
61 net_components_.reset(new ClientNetworkComponents(
62 base::MakeUnique<CrossThreadNetworkEventObserver>(
63 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get())));
64
65 assignment_source_.reset(new AssignmentSource(
66 assigner_endpoint, io_thread_.task_runner(), io_thread_.task_runner()));
67
68 std::unique_ptr<HeliumBlobReceiverDelegate> blob_delegate(
69 new HeliumBlobReceiverDelegate);
70 blob_delegate_ = blob_delegate.get();
71 blob_receiver_ = BlobChannelReceiver::Create(
72 base::WrapUnique(new InMemoryBlobCache), std::move(blob_delegate));
73
74 RegisterFeatures();
75
76 blob_image_processor_.set_blob_receiver(blob_receiver_.get());
77 blob_image_processor_.set_error_delegate(this);
78
79 // Initialize must only be posted after the RegisterFeature calls have
80 // completed.
81 io_thread_.task_runner()->PostTask(
82 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize,
83 base::Unretained(net_components_.get())));
84 }
85
86 BlimpClientSession::~BlimpClientSession() {
87 io_thread_.task_runner()->DeleteSoon(FROM_HERE, net_components_.release());
88 }
89
90 void BlimpClientSession::Connect(const std::string& client_auth_token) {
91 VLOG(1) << "Trying to get assignment.";
92 assignment_source_->GetAssignment(
93 client_auth_token, base::Bind(&BlimpClientSession::ConnectWithAssignment,
94 weak_factory_.GetWeakPtr()));
95 }
96
97 void BlimpClientSession::ConnectWithAssignment(AssignmentRequestResult result,
98 const Assignment& assignment) {
99 OnAssignmentConnectionAttempted(result, assignment);
100
101 if (result != ASSIGNMENT_REQUEST_RESULT_OK) {
102 LOG(ERROR) << "Assignment failed, reason: " << result;
103 return;
104 }
105
106 VLOG(1) << "Assignment succeeded";
107
108 io_thread_.task_runner()->PostTask(
109 FROM_HERE,
110 base::Bind(&ClientNetworkComponents::ConnectWithAssignment,
111 base::Unretained(net_components_.get()), assignment));
112 }
113
114 void BlimpClientSession::OnAssignmentConnectionAttempted(
115 AssignmentRequestResult result,
116 const Assignment& assignment) {}
117
118 void BlimpClientSession::RegisterFeatures() {
119 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>(
120 io_thread_.task_runner(), net_components_->GetBrowserConnectionHandler());
121
122 // Register features' message senders and receivers.
123 geolocation_feature_->set_outgoing_message_processor(
124 thread_pipe_manager_->RegisterFeature(BlimpMessage::kGeolocation,
125 geolocation_feature_.get()));
126 tab_control_feature_->set_outgoing_message_processor(
127 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl,
128 tab_control_feature_.get()));
129 navigation_feature_->set_outgoing_message_processor(
130 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation,
131 navigation_feature_.get()));
132 render_widget_feature_->set_outgoing_input_message_processor(
133 thread_pipe_manager_->RegisterFeature(BlimpMessage::kInput,
134 render_widget_feature_.get()));
135 render_widget_feature_->set_outgoing_compositor_message_processor(
136 thread_pipe_manager_->RegisterFeature(BlimpMessage::kCompositor,
137 render_widget_feature_.get()));
138 thread_pipe_manager_->RegisterFeature(BlimpMessage::kBlobChannel,
139 blob_delegate_);
140
141 // Client will not send send any RenderWidget messages, so don't save the
142 // outgoing BlimpMessageProcessor in the RenderWidgetFeature.
143 thread_pipe_manager_->RegisterFeature(BlimpMessage::kRenderWidget,
144 render_widget_feature_.get());
145
146 ime_feature_->set_outgoing_message_processor(
147 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme,
148 ime_feature_.get()));
149 }
150
151 void BlimpClientSession::DropConnection() {
152 io_thread_.task_runner()->PostTask(
153 FROM_HERE, base::Bind(&DropConnectionOnIOThread, net_components_.get()));
154 }
155
156 void BlimpClientSession::OnConnected() {}
157
158 void BlimpClientSession::OnDisconnected(int result) {}
159
160 void BlimpClientSession::OnImageDecodeError() {
161 DropConnection();
162 }
163
164 TabControlFeature* BlimpClientSession::GetTabControlFeature() const {
165 return tab_control_feature_.get();
166 }
167
168 NavigationFeature* BlimpClientSession::GetNavigationFeature() const {
169 return navigation_feature_.get();
170 }
171
172 ImeFeature* BlimpClientSession::GetImeFeature() const {
173 return ime_feature_.get();
174 }
175
176 RenderWidgetFeature* BlimpClientSession::GetRenderWidgetFeature() const {
177 return render_widget_feature_.get();
178 }
179
180 } // namespace client
181 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/browser_tests/blimp_client_session.h ('k') | blimp/engine/browser_tests/blimp_contents_view_readback_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698