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

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: Include map 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 9
10 namespace blink { 10 namespace blink {
(...skipping 15 matching lines...) Expand all
26 }; 26 };
27 27
28 WebBluetooth* BluetoothSupplement::from(LocalFrame* frame) 28 WebBluetooth* BluetoothSupplement::from(LocalFrame* frame)
29 { 29 {
30 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(WillBeHe apSupplement<LocalFrame>::from(frame, supplementName())); 30 BluetoothSupplement* supplement = static_cast<BluetoothSupplement*>(WillBeHe apSupplement<LocalFrame>::from(frame, supplementName()));
31 if (supplement && supplement->m_bluetooth) 31 if (supplement && supplement->m_bluetooth)
32 return supplement->m_bluetooth; 32 return supplement->m_bluetooth;
33 return nullptr; 33 return nullptr;
34 } 34 }
35 35
36 WebBluetooth* BluetoothSupplement::getFromScriptState(ScriptState* scriptState) 36 static WebBluetooth* getFromLocalDOMWindow(LocalDOMWindow* window)
37 { 37 {
38 LocalDOMWindow* window = scriptState->domWindow();
39 if (window && window->frame()) { 38 if (window && window->frame()) {
haraken 2015/10/10 14:19:35 As commented in the other CL, it is unsafe to use
ortuno 2015/10/12 17:46:07 Using executionContext now.
40 return BluetoothSupplement::from(window->frame()); 39 return BluetoothSupplement::from(window->frame());
41 } 40 }
42 return nullptr; 41 return nullptr;
43 } 42 }
44 43
44 WebBluetooth* BluetoothSupplement::getFromScriptState(ScriptState* scriptState)
45 {
46 return getFromLocalDOMWindow(scriptState->domWindow());
47 }
48
49 WebBluetooth* BluetoothSupplement::getFromExecutionContext(ExecutionContext* exe cutionContext)
50 {
51 return getFromLocalDOMWindow(executionContext->executingWindow());
haraken 2015/10/10 14:19:35 executionContext->executingWindow() may work but i
ortuno 2015/10/12 17:46:07 Done.
52 }
53
45 DEFINE_TRACE(BluetoothSupplement) 54 DEFINE_TRACE(BluetoothSupplement)
46 { 55 {
47 WillBeHeapSupplement<LocalFrame>::trace(visitor); 56 WillBeHeapSupplement<LocalFrame>::trace(visitor);
48 } 57 }
49 58
50 }; // blink 59 }; // blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698