OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include <algorithm> | |
7 #include <utility> | 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
12 #include "base/debug/dump_without_crashing.h" | 13 #include "base/debug/dump_without_crashing.h" |
13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
15 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
16 #include "base/process/kill.h" | 17 #include "base/process/kill.h" |
(...skipping 3205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3222 if (!focused_frame_tree_node) | 3223 if (!focused_frame_tree_node) |
3223 return; | 3224 return; |
3224 RenderFrameHostImpl* focused_frame = | 3225 RenderFrameHostImpl* focused_frame = |
3225 focused_frame_tree_node->current_frame_host(); | 3226 focused_frame_tree_node->current_frame_host(); |
3226 DCHECK(focused_frame); | 3227 DCHECK(focused_frame); |
3227 dst->focused_tree_id = focused_frame->GetAXTreeID(); | 3228 dst->focused_tree_id = focused_frame->GetAXTreeID(); |
3228 } | 3229 } |
3229 | 3230 |
3230 WebBluetoothServiceImpl* RenderFrameHostImpl::CreateWebBluetoothService( | 3231 WebBluetoothServiceImpl* RenderFrameHostImpl::CreateWebBluetoothService( |
3231 blink::mojom::WebBluetoothServiceRequest request) { | 3232 blink::mojom::WebBluetoothServiceRequest request) { |
3232 DCHECK(!web_bluetooth_service_); | 3233 // RFHI owns |web_bluetooth_services_| and |web_bluetooth_service| owns the |
3233 web_bluetooth_service_.reset( | 3234 // |binding_| which may run the error handler. |binding_| can't run the error |
3234 new WebBluetoothServiceImpl(this, std::move(request))); | |
3235 // RFHI owns web_bluetooth_service_ and web_bluetooth_service owns the | |
3236 // binding_ which may run the error handler. binding_ can't run the error | |
3237 // handler after it's destroyed so it can't run after the RFHI is destroyed. | 3235 // handler after it's destroyed so it can't run after the RFHI is destroyed. |
3238 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( | 3236 std::unique_ptr<WebBluetoothServiceImpl> web_bluetooth_service = |
dcheng
2016/12/27 20:37:37
Nit: OK to use auto here.
juncai
2016/12/27 21:55:50
Done.
| |
3239 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); | 3237 base::MakeUnique<WebBluetoothServiceImpl>(this, std::move(request)); |
3240 return web_bluetooth_service_.get(); | 3238 web_bluetooth_service->SetClientConnectionErrorHandler( |
3239 base::Bind(&RenderFrameHostImpl::DeleteWebBluetoothService, | |
3240 base::Unretained(this), web_bluetooth_service.get())); | |
3241 web_bluetooth_services_.push_back(std::move(web_bluetooth_service)); | |
dcheng
2016/12/27 20:37:37
That being said, I've read the code a bit more: I'
Reilly Grant (use Gerrit)
2016/12/27 20:45:47
Yes, this is a common pattern for Mojo service imp
| |
3242 return web_bluetooth_services_.back().get(); | |
3241 } | 3243 } |
3242 | 3244 |
3243 void RenderFrameHostImpl::DeleteWebBluetoothService() { | 3245 void RenderFrameHostImpl::DeleteWebBluetoothService( |
3244 web_bluetooth_service_.reset(); | 3246 WebBluetoothServiceImpl* web_bluetooth_service) { |
3247 auto it = std::find_if( | |
3248 web_bluetooth_services_.begin(), web_bluetooth_services_.end(), | |
3249 [web_bluetooth_service]( | |
3250 const std::unique_ptr<WebBluetoothServiceImpl>& service) { | |
3251 return web_bluetooth_service == service.get(); | |
3252 }); | |
3253 DCHECK(it != web_bluetooth_services_.end()); | |
3254 web_bluetooth_services_.erase(it); | |
3245 } | 3255 } |
3246 | 3256 |
3247 void RenderFrameHostImpl::Create( | 3257 void RenderFrameHostImpl::Create( |
3248 const service_manager::Identity& remote_identity, | 3258 const service_manager::Identity& remote_identity, |
3249 media::mojom::InterfaceFactoryRequest request) { | 3259 media::mojom::InterfaceFactoryRequest request) { |
3250 DCHECK(!media_interface_proxy_); | 3260 DCHECK(!media_interface_proxy_); |
3251 media_interface_proxy_.reset(new MediaInterfaceProxy( | 3261 media_interface_proxy_.reset(new MediaInterfaceProxy( |
3252 this, std::move(request), | 3262 this, std::move(request), |
3253 base::Bind(&RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError, | 3263 base::Bind(&RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError, |
3254 base::Unretained(this)))); | 3264 base::Unretained(this)))); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3337 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3347 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3338 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3348 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3339 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3349 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3340 return NavigationHandleImpl::Create( | 3350 return NavigationHandleImpl::Create( |
3341 params.url, frame_tree_node_, is_renderer_initiated, | 3351 params.url, frame_tree_node_, is_renderer_initiated, |
3342 params.was_within_same_page, base::TimeTicks::Now(), | 3352 params.was_within_same_page, base::TimeTicks::Now(), |
3343 entry_id_for_data_nav, false); // started_from_context_menu | 3353 entry_id_for_data_nav, false); // started_from_context_menu |
3344 } | 3354 } |
3345 | 3355 |
3346 } // namespace content | 3356 } // namespace content |
OLD | NEW |