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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2565913002: [Onion Soup] Move WebBluetoothImpl from //content/renderer/bluetooth to Blink's bluetooth module (Closed)
Patch Set: address comments Created 4 years 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 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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/debug/dump_without_crashing.h" 12 #include "base/debug/dump_without_crashing.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/process/kill.h" 16 #include "base/process/kill.h"
17 #include "base/stl_util.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "content/browser/accessibility/ax_tree_id_registry.h" 20 #include "content/browser/accessibility/ax_tree_id_registry.h"
20 #include "content/browser/accessibility/browser_accessibility_manager.h" 21 #include "content/browser/accessibility/browser_accessibility_manager.h"
21 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 22 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
22 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" 23 #include "content/browser/bluetooth/web_bluetooth_service_impl.h"
23 #include "content/browser/browser_main_loop.h" 24 #include "content/browser/browser_main_loop.h"
24 #include "content/browser/child_process_security_policy_impl.h" 25 #include "content/browser/child_process_security_policy_impl.h"
25 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 26 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
26 #include "content/browser/download/mhtml_generation_manager.h" 27 #include "content/browser/download/mhtml_generation_manager.h"
(...skipping 3174 matching lines...) Expand 10 before | Expand all | Expand 10 after
3201 if (!focused_frame_tree_node) 3202 if (!focused_frame_tree_node)
3202 return; 3203 return;
3203 RenderFrameHostImpl* focused_frame = 3204 RenderFrameHostImpl* focused_frame =
3204 focused_frame_tree_node->current_frame_host(); 3205 focused_frame_tree_node->current_frame_host();
3205 DCHECK(focused_frame); 3206 DCHECK(focused_frame);
3206 dst->focused_tree_id = focused_frame->GetAXTreeID(); 3207 dst->focused_tree_id = focused_frame->GetAXTreeID();
3207 } 3208 }
3208 3209
3209 WebBluetoothServiceImpl* RenderFrameHostImpl::CreateWebBluetoothService( 3210 WebBluetoothServiceImpl* RenderFrameHostImpl::CreateWebBluetoothService(
3210 blink::mojom::WebBluetoothServiceRequest request) { 3211 blink::mojom::WebBluetoothServiceRequest request) {
3211 DCHECK(!web_bluetooth_service_); 3212 // RFHI owns |web_bluetooth_services_| and |web_bluetooth_service| owns the
3212 web_bluetooth_service_.reset( 3213 // |binding_| which may run the error handler. |binding_| can't run the error
3213 new WebBluetoothServiceImpl(this, std::move(request)));
3214 // RFHI owns web_bluetooth_service_ and web_bluetooth_service owns the
3215 // binding_ which may run the error handler. binding_ can't run the error
3216 // handler after it's destroyed so it can't run after the RFHI is destroyed. 3214 // handler after it's destroyed so it can't run after the RFHI is destroyed.
3217 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( 3215 std::unique_ptr<WebBluetoothServiceImpl> web_bluetooth_service =
3218 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); 3216 base::MakeUnique<WebBluetoothServiceImpl>(this, std::move(request));
3219 return web_bluetooth_service_.get(); 3217 web_bluetooth_service->SetClientConnectionErrorHandler(
3218 base::Bind(&RenderFrameHostImpl::DeleteWebBluetoothService,
3219 base::Unretained(this), web_bluetooth_service.get()));
3220 auto it = web_bluetooth_services_.insert(std::move(web_bluetooth_service));
3221 return it.first->get();
3220 } 3222 }
3221 3223
3222 void RenderFrameHostImpl::DeleteWebBluetoothService() { 3224 void RenderFrameHostImpl::DeleteWebBluetoothService(
3223 web_bluetooth_service_.reset(); 3225 WebBluetoothServiceImpl* web_bluetooth_service) {
3226 auto it = web_bluetooth_services_.find(
3227 base::FakeUniquePtr<WebBluetoothServiceImpl>(web_bluetooth_service));
Reilly Grant (use Gerrit) 2016/12/20 02:08:16 Add a helper method base::MakeFakeUniquePtr() so t
juncai 2016/12/20 22:33:42 Discussed offline with reillyg@, using base::FakeU
3228 DCHECK(it != web_bluetooth_services_.end());
3229 web_bluetooth_services_.erase(it);
3224 } 3230 }
3225 3231
3226 void RenderFrameHostImpl::Create( 3232 void RenderFrameHostImpl::Create(
3227 const service_manager::Identity& remote_identity, 3233 const service_manager::Identity& remote_identity,
3228 media::mojom::InterfaceFactoryRequest request) { 3234 media::mojom::InterfaceFactoryRequest request) {
3229 DCHECK(!media_interface_proxy_); 3235 DCHECK(!media_interface_proxy_);
3230 media_interface_proxy_.reset(new MediaInterfaceProxy( 3236 media_interface_proxy_.reset(new MediaInterfaceProxy(
3231 this, std::move(request), 3237 this, std::move(request),
3232 base::Bind(&RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError, 3238 base::Bind(&RenderFrameHostImpl::OnMediaInterfaceFactoryConnectionError,
3233 base::Unretained(this)))); 3239 base::Unretained(this))));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 // There is no pending NavigationEntry in these cases, so pass 0 as the 3322 // There is no pending NavigationEntry in these cases, so pass 0 as the
3317 // pending_nav_entry_id. If the previous handle was a prematurely aborted 3323 // pending_nav_entry_id. If the previous handle was a prematurely aborted
3318 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. 3324 // navigation loaded via LoadDataWithBaseURL, propagate the entry id.
3319 return NavigationHandleImpl::Create( 3325 return NavigationHandleImpl::Create(
3320 params.url, frame_tree_node_, is_renderer_initiated, 3326 params.url, frame_tree_node_, is_renderer_initiated,
3321 params.was_within_same_page, base::TimeTicks::Now(), 3327 params.was_within_same_page, base::TimeTicks::Now(),
3322 entry_id_for_data_nav, false); // started_from_context_menu 3328 entry_id_for_data_nav, false); // started_from_context_menu
3323 } 3329 }
3324 3330
3325 } // namespace content 3331 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698