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

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

Issue 2249283003: Hooks together Geolocation Feature in the Client and Engine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lai
Patch Set: Addresses nyquist's #9 comments. 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 #include "blimp/client/core/blimp_client_context_impl.h" 5 #include "blimp/client/core/blimp_client_context_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/threading/sequenced_task_runner_handle.h" 10 #include "base/threading/sequenced_task_runner_handle.h"
11 #include "blimp/client/core/contents/blimp_contents_impl.h" 11 #include "blimp/client/core/contents/blimp_contents_impl.h"
12 #include "blimp/client/core/contents/blimp_contents_manager.h" 12 #include "blimp/client/core/contents/blimp_contents_manager.h"
13 #include "blimp/client/core/geolocation/blimp_location_provider.h"
14 #include "blimp/client/core/geolocation/geolocation_feature.h"
13 #include "blimp/client/core/session/cross_thread_network_event_observer.h" 15 #include "blimp/client/core/session/cross_thread_network_event_observer.h"
14 #include "blimp/client/public/blimp_client_context_delegate.h" 16 #include "blimp/client/public/blimp_client_context_delegate.h"
15 17
16 #if defined(OS_ANDROID) 18 #if defined(OS_ANDROID)
17 #include "blimp/client/core/android/blimp_client_context_impl_android.h" 19 #include "blimp/client/core/android/blimp_client_context_impl_android.h"
18 #endif // OS_ANDROID 20 #endif // OS_ANDROID
19 21
20 namespace blimp { 22 namespace blimp {
21 namespace client { 23 namespace client {
22 24
(...skipping 19 matching lines...) Expand all
42 #endif // defined(OS_ANDROID) 44 #endif // defined(OS_ANDROID)
43 } 45 }
44 46
45 BlimpClientContextImpl::BlimpClientContextImpl( 47 BlimpClientContextImpl::BlimpClientContextImpl(
46 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, 48 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
47 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner) 49 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner)
48 : BlimpClientContext(), 50 : BlimpClientContext(),
49 io_thread_task_runner_(io_thread_task_runner), 51 io_thread_task_runner_(io_thread_task_runner),
50 file_thread_task_runner_(file_thread_task_runner), 52 file_thread_task_runner_(file_thread_task_runner),
51 blimp_contents_manager_(new BlimpContentsManager), 53 blimp_contents_manager_(new BlimpContentsManager),
54 geolocation_feature_(new GeolocationFeature(
Kevin M 2016/08/19 17:51:37 How come this is stored in both the ClientContext
CJ 2016/08/19 20:44:01 nyquist's suggestion. Based on what was discussed
55 base::MakeUnique<BlimpLocationProvider>())),
52 weak_factory_(this) { 56 weak_factory_(this) {
53 net_components_.reset(new ClientNetworkComponents( 57 net_components_.reset(new ClientNetworkComponents(
54 base::MakeUnique<CrossThreadNetworkEventObserver>( 58 base::MakeUnique<CrossThreadNetworkEventObserver>(
55 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()))); 59 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get())));
56 60
57 // The |thread_pipe_manager_| must be set up correctly before features are 61 // The |thread_pipe_manager_| must be set up correctly before features are
58 // registered. 62 // registered.
59 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( 63 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>(
60 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); 64 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler());
61 65
66 RegisterFeatures();
67
62 // Initialize must only be posted after the calls features have been 68 // Initialize must only be posted after the calls features have been
63 // registered. 69 // registered.
Wez 2016/08/19 23:12:10 nit: While you're here can you correct this typo,
CJ 2016/08/22 20:28:08 Done.
64 io_thread_task_runner_->PostTask( 70 io_thread_task_runner_->PostTask(
65 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, 71 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize,
66 base::Unretained(net_components_.get()))); 72 base::Unretained(net_components_.get())));
67 } 73 }
68 74
69 BlimpClientContextImpl::~BlimpClientContextImpl() { 75 BlimpClientContextImpl::~BlimpClientContextImpl() {
70 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); 76 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release());
71 } 77 }
72 78
73 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { 79 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 LOG(ERROR) << "Assignment failed, reason: " << result; 121 LOG(ERROR) << "Assignment failed, reason: " << result;
116 return; 122 return;
117 } 123 }
118 124
119 io_thread_task_runner_->PostTask( 125 io_thread_task_runner_->PostTask(
120 FROM_HERE, 126 FROM_HERE,
121 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, 127 base::Bind(&ClientNetworkComponents::ConnectWithAssignment,
122 base::Unretained(net_components_.get()), assignment)); 128 base::Unretained(net_components_.get()), assignment));
123 } 129 }
124 130
131 void BlimpClientContextImpl::RegisterFeatures() {
132 // Register features' message senders and receivers.
Kevin M 2016/08/19 17:51:37 Move this comment to the .h file
CJ 2016/08/19 20:44:01 Done.
133 geolocation_feature_->set_outgoing_message_processor(
134 thread_pipe_manager_->RegisterFeature(BlimpMessage::kGeolocation,
135 geolocation_feature_.get()));
136 }
137
125 } // namespace client 138 } // namespace client
126 } // namespace blimp 139 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698