| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "modules/beacon/NavigatorBeacon.h" | 5 #include "modules/beacon/NavigatorBeacon.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h" | 8 #include "bindings/modules/v8/ArrayBufferViewOrBlobOrStringOrFormData.h" |
| 9 #include "core/dom/DOMArrayBufferView.h" | 9 #include "core/dom/DOMArrayBufferView.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (!frame() || !frame()->client()) | 73 if (!frame() || !frame()->client()) |
| 74 return false; | 74 return false; |
| 75 | 75 |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| 78 | 78 |
| 79 int NavigatorBeacon::maxAllowance() const { | 79 int NavigatorBeacon::maxAllowance() const { |
| 80 DCHECK(frame()); | 80 DCHECK(frame()); |
| 81 const Settings* settings = frame()->settings(); | 81 const Settings* settings = frame()->settings(); |
| 82 if (settings) { | 82 if (settings) { |
| 83 int maxAllowed = settings->maxBeaconTransmission(); | 83 int maxAllowed = settings->getMaxBeaconTransmission(); |
| 84 if (maxAllowed < m_transmittedBytes) | 84 if (maxAllowed < m_transmittedBytes) |
| 85 return 0; | 85 return 0; |
| 86 return maxAllowed - m_transmittedBytes; | 86 return maxAllowed - m_transmittedBytes; |
| 87 } | 87 } |
| 88 return m_transmittedBytes; | 88 return m_transmittedBytes; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void NavigatorBeacon::addTransmittedBytes(int sentBytes) { | 91 void NavigatorBeacon::addTransmittedBytes(int sentBytes) { |
| 92 DCHECK_GE(sentBytes, 0); | 92 DCHECK_GE(sentBytes, 0); |
| 93 m_transmittedBytes += sentBytes; | 93 m_transmittedBytes += sentBytes; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 if (allowed) { | 141 if (allowed) { |
| 142 impl.addTransmittedBytes(bytes); | 142 impl.addTransmittedBytes(bytes); |
| 143 return true; | 143 return true; |
| 144 } | 144 } |
| 145 | 145 |
| 146 UseCounter::count(context, UseCounter::SendBeaconQuotaExceeded); | 146 UseCounter::count(context, UseCounter::SendBeaconQuotaExceeded); |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace blink | 150 } // namespace blink |
| OLD | NEW |