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

Side by Side Diff: content/shell/browser/layout_test/blink_test_controller.cc

Issue 2658473002: Refactor BluetoothAllowedDevicesMap (Closed)
Patch Set: updated test code Created 3 years, 10 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 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/shell/browser/layout_test/blink_test_controller.h" 5 #include "content/shell/browser/layout_test/blink_test_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <iostream> 9 #include <iostream>
10 #include <set> 10 #include <set>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/base64.h" 13 #include "base/base64.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
21 #include "base/stl_util.h" 21 #include "base/stl_util.h"
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/threading/thread_task_runner_handle.h" 24 #include "base/threading/thread_task_runner_handle.h"
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "content/public/browser/bluetooth_allowed_devices_map_base.h"
27 #include "content/public/browser/browser_context.h"
26 #include "content/public/browser/devtools_agent_host.h" 28 #include "content/public/browser/devtools_agent_host.h"
27 #include "content/public/browser/dom_storage_context.h" 29 #include "content/public/browser/dom_storage_context.h"
28 #include "content/public/browser/gpu_data_manager.h" 30 #include "content/public/browser/gpu_data_manager.h"
29 #include "content/public/browser/navigation_controller.h" 31 #include "content/public/browser/navigation_controller.h"
30 #include "content/public/browser/navigation_entry.h" 32 #include "content/public/browser/navigation_entry.h"
31 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
32 #include "content/public/browser/notification_types.h" 34 #include "content/public/browser/notification_types.h"
33 #include "content/public/browser/render_frame_host.h" 35 #include "content/public/browser/render_frame_host.h"
34 #include "content/public/browser/render_process_host.h" 36 #include "content/public/browser/render_process_host.h"
35 #include "content/public/browser/render_view_host.h" 37 #include "content/public/browser/render_view_host.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 std::unique_ptr<BluetoothChooser> BlinkTestController::RunBluetoothChooser( 410 std::unique_ptr<BluetoothChooser> BlinkTestController::RunBluetoothChooser(
409 RenderFrameHost* frame, 411 RenderFrameHost* frame,
410 const BluetoothChooser::EventHandler& event_handler) { 412 const BluetoothChooser::EventHandler& event_handler) {
411 if (bluetooth_chooser_factory_) { 413 if (bluetooth_chooser_factory_) {
412 return bluetooth_chooser_factory_->RunBluetoothChooser(frame, 414 return bluetooth_chooser_factory_->RunBluetoothChooser(frame,
413 event_handler); 415 event_handler);
414 } 416 }
415 return base::MakeUnique<LayoutTestFirstDeviceBluetoothChooser>(event_handler); 417 return base::MakeUnique<LayoutTestFirstDeviceBluetoothChooser>(event_handler);
416 } 418 }
417 419
420 BluetoothAllowedDevicesMapBase*
421 BlinkTestController::GetBluetoothAllowedDevicesMap(
422 BrowserContext* browser_context) {
423 auto iter =
424 browser_contenxt_to_bluetooth_allowed_devices_map_.find(browser_context);
425 if (iter == browser_contenxt_to_bluetooth_allowed_devices_map_.end()) {
426 iter = browser_contenxt_to_bluetooth_allowed_devices_map_.insert(
427 iter,
428 std::make_pair(browser_context,
429 base::MakeUnique<BluetoothAllowedDevicesMapBase>()));
430 }
431 return iter->second.get();
432 }
433
418 bool BlinkTestController::OnMessageReceived(const IPC::Message& message) { 434 bool BlinkTestController::OnMessageReceived(const IPC::Message& message) {
419 DCHECK(CalledOnValidThread()); 435 DCHECK(CalledOnValidThread());
420 bool handled = true; 436 bool handled = true;
421 IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message) 437 IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message)
422 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage) 438 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage)
423 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) 439 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump)
424 IPC_MESSAGE_HANDLER(ShellViewHostMsg_InitiateLayoutDump, 440 IPC_MESSAGE_HANDLER(ShellViewHostMsg_InitiateLayoutDump,
425 OnInitiateLayoutDump) 441 OnInitiateLayoutDump)
426 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump) 442 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump)
427 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump) 443 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump)
(...skipping 14 matching lines...) Expand all
442 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseRemainingWindows, 458 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseRemainingWindows,
443 OnCloseRemainingWindows) 459 OnCloseRemainingWindows)
444 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone) 460 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone)
445 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LeakDetectionDone, OnLeakDetectionDone) 461 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LeakDetectionDone, OnLeakDetectionDone)
446 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SetBluetoothManualChooser, 462 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SetBluetoothManualChooser,
447 OnSetBluetoothManualChooser) 463 OnSetBluetoothManualChooser)
448 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GetBluetoothManualChooserEvents, 464 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GetBluetoothManualChooserEvents,
449 OnGetBluetoothManualChooserEvents) 465 OnGetBluetoothManualChooserEvents)
450 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SendBluetoothManualChooserEvent, 466 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SendBluetoothManualChooserEvent,
451 OnSendBluetoothManualChooserEvent) 467 OnSendBluetoothManualChooserEvent)
468 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetBluetoothAllowedDevicesMap,
469 OnResetBluetoothAllowedDevicesMap)
452 IPC_MESSAGE_UNHANDLED(handled = false) 470 IPC_MESSAGE_UNHANDLED(handled = false)
453 IPC_END_MESSAGE_MAP() 471 IPC_END_MESSAGE_MAP()
454 472
455 return handled; 473 return handled;
456 } 474 }
457 475
458 bool BlinkTestController::OnMessageReceived( 476 bool BlinkTestController::OnMessageReceived(
459 const IPC::Message& message, 477 const IPC::Message& message,
460 RenderFrameHost* render_frame_host) { 478 RenderFrameHost* render_frame_host) {
461 bool handled = true; 479 bool handled = true;
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 mojom::LayoutTestControl* BlinkTestController::GetLayoutTestControlPtr( 985 mojom::LayoutTestControl* BlinkTestController::GetLayoutTestControlPtr(
968 RenderFrameHost* frame) { 986 RenderFrameHost* frame) {
969 if (layout_test_control_map_.find(frame) == layout_test_control_map_.end()) { 987 if (layout_test_control_map_.find(frame) == layout_test_control_map_.end()) {
970 frame->GetRemoteAssociatedInterfaces()->GetInterface( 988 frame->GetRemoteAssociatedInterfaces()->GetInterface(
971 &layout_test_control_map_[frame]); 989 &layout_test_control_map_[frame]);
972 } 990 }
973 DCHECK(layout_test_control_map_[frame].get()); 991 DCHECK(layout_test_control_map_[frame].get());
974 return layout_test_control_map_[frame].get(); 992 return layout_test_control_map_[frame].get();
975 } 993 }
976 994
995 void BlinkTestController::OnResetBluetoothAllowedDevicesMap() {
996 browser_contenxt_to_bluetooth_allowed_devices_map_.clear();
997 }
998
977 } // namespace content 999 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698