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

Unified Diff: Source/modules/beacon/NavigatorBeacon.cpp

Issue 1101263003: Oilpan: have Navigator and its supplements be on the heap by default. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make NavigatorBeacon a frame observer instead Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/beacon/NavigatorBeacon.h ('k') | Source/modules/bluetooth/NavigatorBluetooth.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/beacon/NavigatorBeacon.cpp
diff --git a/Source/modules/beacon/NavigatorBeacon.cpp b/Source/modules/beacon/NavigatorBeacon.cpp
index 990ef896287ec354ab0d546b710ed1d29daaa382..e1b2ba1afef7175fad7b4733612695c11ba156ef 100644
--- a/Source/modules/beacon/NavigatorBeacon.cpp
+++ b/Source/modules/beacon/NavigatorBeacon.cpp
@@ -21,14 +21,19 @@
namespace blink {
NavigatorBeacon::NavigatorBeacon(Navigator& navigator)
- : m_transmittedBytes(0)
- , m_navigator(navigator)
+ : LocalFrameLifecycleObserver(navigator.frame())
+ , m_transmittedBytes(0)
+{
+}
+
+NavigatorBeacon::~NavigatorBeacon()
{
}
DEFINE_TRACE(NavigatorBeacon)
{
- WillBeHeapSupplement<Navigator>::trace(visitor);
+ LocalFrameLifecycleObserver::trace(visitor);
+ HeapSupplement<Navigator>::trace(visitor);
}
const char* NavigatorBeacon::supplementName()
@@ -38,10 +43,10 @@ const char* NavigatorBeacon::supplementName()
NavigatorBeacon& NavigatorBeacon::from(Navigator& navigator)
{
- NavigatorBeacon* supplement = static_cast<NavigatorBeacon*>(WillBeHeapSupplement<Navigator>::from(navigator, supplementName()));
+ NavigatorBeacon* supplement = static_cast<NavigatorBeacon*>(HeapSupplement<Navigator>::from(navigator, supplementName()));
if (!supplement) {
supplement = new NavigatorBeacon(navigator);
- provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
+ provideTo(navigator, supplementName(), supplement);
}
return *supplement;
}
@@ -64,8 +69,8 @@ bool NavigatorBeacon::canSendBeacon(ExecutionContext* context, const KURL& url,
return false;
}
- // Do not allow sending Beacons over a Navigator that is detached.
- if (!m_navigator.frame() || !m_navigator.frame()->client())
+ // If detached from frame, do not allow sending a Beacon.
+ if (!frame() || !frame()->client())
return false;
return true;
@@ -73,7 +78,8 @@ bool NavigatorBeacon::canSendBeacon(ExecutionContext* context, const KURL& url,
int NavigatorBeacon::maxAllowance() const
{
- const Settings* settings = m_navigator.frame()->settings();
+ ASSERT(frame());
+ const Settings* settings = frame()->settings();
if (settings) {
int maxAllowed = settings->maxBeaconTransmission();
if (maxAllowed < m_transmittedBytes)
@@ -107,15 +113,15 @@ bool NavigatorBeacon::sendBeacon(ExecutionContext* context, Navigator& navigator
bool allowed;
if (data.isArrayBufferView())
- allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, data.getAsArrayBufferView(), bytes);
+ allowed = BeaconLoader::sendBeacon(impl.frame(), allowance, url, data.getAsArrayBufferView(), bytes);
haraken 2015/04/25 08:15:00 navigator.frame() and impl.frame() are guarnateed
sof 2015/04/25 08:19:34 Yes, doesn't it make sense to work over the 'this'
haraken 2015/04/25 08:31:14 Makes sense.
else if (data.isBlob())
- allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, data.getAsBlob(), bytes);
+ allowed = BeaconLoader::sendBeacon(impl.frame(), allowance, url, data.getAsBlob(), bytes);
else if (data.isString())
- allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, data.getAsString(), bytes);
+ allowed = BeaconLoader::sendBeacon(impl.frame(), allowance, url, data.getAsString(), bytes);
else if (data.isFormData())
- allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, data.getAsFormData(), bytes);
+ allowed = BeaconLoader::sendBeacon(impl.frame(), allowance, url, data.getAsFormData(), bytes);
else
- allowed = BeaconLoader::sendBeacon(navigator.frame(), allowance, url, String(), bytes);
+ allowed = BeaconLoader::sendBeacon(impl.frame(), allowance, url, String(), bytes);
return impl.beaconResult(context, allowed, bytes);
}
« no previous file with comments | « Source/modules/beacon/NavigatorBeacon.h ('k') | Source/modules/bluetooth/NavigatorBluetooth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698