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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothSupplement.cpp

Issue 1334763002: bluetooth: Subscribe to notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-origin
Patch Set: Address haraken's comments Created 5 years, 2 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 2015 The Chromium Authors. All rights reserved. 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 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 "config.h" 5 #include "config.h"
6 #include "modules/bluetooth/BluetoothSupplement.h" 6 #include "modules/bluetooth/BluetoothSupplement.h"
7 7
8 #include "core/frame/LocalDOMWindow.h" 8 #include "core/frame/LocalDOMWindow.h"
9 #include "public/platform/Platform.h" 9 #include "public/platform/Platform.h"
10 10
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth) 23 void BluetoothSupplement::provideTo(LocalFrame& frame, WebBluetooth* bluetooth)
24 { 24 {
25 OwnPtrWillBeRawPtr<BluetoothSupplement> bluetoothSupplement = adoptPtrWillBe Noop(new BluetoothSupplement(bluetooth)); 25 OwnPtrWillBeRawPtr<BluetoothSupplement> bluetoothSupplement = adoptPtrWillBe Noop(new BluetoothSupplement(bluetooth));
26 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), bluetoo thSupplement.release()); 26 WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), bluetoo thSupplement.release());
27 }; 27 };
28 28
29 WebBluetooth* BluetoothSupplement::from(ScriptState* scriptState) 29 WebBluetooth* BluetoothSupplement::from(ScriptState* scriptState)
30 { 30 {
31 LocalDOMWindow* window = scriptState->domWindow(); 31 return BluetoothSupplement::from(scriptState->domWindow());
32 }
33
34 WebBluetooth* BluetoothSupplement::from(ExecutionContext* executionContext)
35 {
36 return BluetoothSupplement::from(executionContext->executingWindow());
37 }
38
39 WebBluetooth* BluetoothSupplement::from(LocalDOMWindow* window)
40 {
32 if (window && window->frame()) { 41 if (window && window->frame()) {
33 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(Will BeHeapSupplement<LocalFrame>::from(window->frame(), supplementName())); 42 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(Will BeHeapSupplement<LocalFrame>::from(window->frame(), supplementName()));
34 if (supplement && supplement->m_bluetooth) 43 if (supplement && supplement->m_bluetooth)
35 return supplement->m_bluetooth; 44 return supplement->m_bluetooth;
36 } 45 }
37 return Platform::current()->bluetooth(); 46 return Platform::current()->bluetooth();
haraken 2015/10/08 00:51:52 We sometimes return a bluetooth of the frame and s
ortuno 2015/10/08 16:07:45 If the frame is gone then window->frame() would be
38 } 47 }
39 48
40 DEFINE_TRACE(BluetoothSupplement) 49 DEFINE_TRACE(BluetoothSupplement)
41 { 50 {
42 WillBeHeapSupplement<LocalFrame>::trace(visitor); 51 WillBeHeapSupplement<LocalFrame>::trace(visitor);
43 } 52 }
44 53
45 }; // blink 54 }; // blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BluetoothSupplement.h ('k') | third_party/WebKit/public/blink_headers.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698