Commit 855ec4bc authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Fix 64 bit truncation issues in renderer/modules

Use wtf_size_t where appropriate.

BUG=879657

Change-Id: I26f766e7f6f29c6beaf0d396d665f1eba1235d83
Reviewed-on: https://chromium-review.googlesource.com/c/1298246
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603101}
parent 0a8ce562
...@@ -52,7 +52,7 @@ class CORE_EXPORT LayoutWorklet : public Worklet, ...@@ -52,7 +52,7 @@ class CORE_EXPORT LayoutWorklet : public Worklet,
explicit LayoutWorklet(LocalFrame*); explicit LayoutWorklet(LocalFrame*);
// TODO(ikilpatrick): Make selection of the global scope non-deterministic. // TODO(ikilpatrick): Make selection of the global scope non-deterministic.
size_t SelectGlobalScope() final { return 0u; } wtf_size_t SelectGlobalScope() final { return 0u; }
private: private:
friend class LayoutWorkletTest; friend class LayoutWorkletTest;
......
...@@ -113,7 +113,7 @@ WorkletGlobalScopeProxy* TaskWorklet::CreateGlobalScope() { ...@@ -113,7 +113,7 @@ WorkletGlobalScopeProxy* TaskWorklet::CreateGlobalScope() {
} }
// We select a global scope without this getting called. // We select a global scope without this getting called.
size_t TaskWorklet::SelectGlobalScope() { wtf_size_t TaskWorklet::SelectGlobalScope() {
NOTREACHED(); NOTREACHED();
return 0u; return 0u;
} }
......
...@@ -41,7 +41,7 @@ class TaskWorklet final : public Worklet, ...@@ -41,7 +41,7 @@ class TaskWorklet final : public Worklet,
bool NeedsToCreateGlobalScope() final; bool NeedsToCreateGlobalScope() final;
WorkletGlobalScopeProxy* CreateGlobalScope() final; WorkletGlobalScopeProxy* CreateGlobalScope() final;
size_t SelectGlobalScope() final; wtf_size_t SelectGlobalScope() final;
}; };
} // namespace blink } // namespace blink
......
...@@ -164,7 +164,7 @@ void Worklet::FetchAndInvokeScript(const KURL& module_url_record, ...@@ -164,7 +164,7 @@ void Worklet::FetchAndInvokeScript(const KURL& module_url_record,
} }
} }
size_t Worklet::SelectGlobalScope() { wtf_size_t Worklet::SelectGlobalScope() {
DCHECK_EQ(GetNumberOfGlobalScopes(), 1u); DCHECK_EQ(GetNumberOfGlobalScopes(), 1u);
return 0u; return 0u;
} }
......
...@@ -58,7 +58,7 @@ class CORE_EXPORT Worklet : public ScriptWrappable, ...@@ -58,7 +58,7 @@ class CORE_EXPORT Worklet : public ScriptWrappable,
// Returns one of available global scopes. // Returns one of available global scopes.
WorkletGlobalScopeProxy* FindAvailableGlobalScope(); WorkletGlobalScopeProxy* FindAvailableGlobalScope();
size_t GetNumberOfGlobalScopes() const { return proxies_.size(); } wtf_size_t GetNumberOfGlobalScopes() const { return proxies_.size(); }
WorkletModuleResponsesMap* ModuleResponsesMap() const { WorkletModuleResponsesMap* ModuleResponsesMap() const {
return module_responses_map_.Get(); return module_responses_map_.Get();
...@@ -85,7 +85,7 @@ class CORE_EXPORT Worklet : public ScriptWrappable, ...@@ -85,7 +85,7 @@ class CORE_EXPORT Worklet : public ScriptWrappable,
// there are multiple global scopes, this function MUST be overriden. The // there are multiple global scopes, this function MUST be overriden. The
// default behavior is to return the global scope at index 0, which is for the // default behavior is to return the global scope at index 0, which is for the
// case where there is only one global scope. // case where there is only one global scope.
virtual size_t SelectGlobalScope(); virtual wtf_size_t SelectGlobalScope();
// "A Worklet has a module responses map. This is a ordered map of module URLs // "A Worklet has a module responses map. This is a ordered map of module URLs
// to values that are a fetch responses. The map's entries are ordered based // to values that are a fetch responses. The map's entries are ordered based
// on their insertion order. Access to this map should be thread-safe." // on their insertion order. Access to this map should be thread-safe."
......
...@@ -66,9 +66,9 @@ OffscreenCanvas* HTMLCanvasElementModule::TransferControlToOffscreenInternal( ...@@ -66,9 +66,9 @@ OffscreenCanvas* HTMLCanvasElementModule::TransferControlToOffscreenInternal(
OffscreenCanvas* offscreen_canvas = OffscreenCanvas* offscreen_canvas =
OffscreenCanvas::Create(canvas.width(), canvas.height()); OffscreenCanvas::Create(canvas.width(), canvas.height());
int canvas_id = DOMNodeIds::IdForNode(&canvas); DOMNodeId canvas_id = DOMNodeIds::IdForNode(&canvas);
offscreen_canvas->SetPlaceholderCanvasId(canvas_id); offscreen_canvas->SetPlaceholderCanvasId(canvas_id);
canvas.RegisterPlaceholder(canvas_id); canvas.RegisterPlaceholder(static_cast<int>(canvas_id));
SurfaceLayerBridge* bridge = canvas.SurfaceLayerBridge(); SurfaceLayerBridge* bridge = canvas.SurfaceLayerBridge();
if (bridge) { if (bridge) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace blink { namespace blink {
const size_t PaintWorklet::kNumGlobalScopes = 2u; const wtf_size_t PaintWorklet::kNumGlobalScopes = 2u;
const size_t kMaxPaintCountToSwitch = 30u; const size_t kMaxPaintCountToSwitch = 30u;
DocumentPaintDefinition* const kInvalidDocumentPaintDefinition = nullptr; DocumentPaintDefinition* const kInvalidDocumentPaintDefinition = nullptr;
...@@ -52,7 +52,7 @@ void PaintWorklet::AddPendingGenerator(const String& name, ...@@ -52,7 +52,7 @@ void PaintWorklet::AddPendingGenerator(const String& name,
// calls (rand(kMaxPaintCountToSwitch)). // calls (rand(kMaxPaintCountToSwitch)).
// This approach ensures non-deterministic of global scope selecting, and that // This approach ensures non-deterministic of global scope selecting, and that
// there is a max of one switching within one frame. // there is a max of one switching within one frame.
size_t PaintWorklet::SelectGlobalScope() { wtf_size_t PaintWorklet::SelectGlobalScope() {
size_t current_paint_frame_count = GetFrame()->View()->PaintFrameCount(); size_t current_paint_frame_count = GetFrame()->View()->PaintFrameCount();
// Whether a new frame starts or not. // Whether a new frame starts or not.
bool frame_changed = current_paint_frame_count != active_frame_count_; bool frame_changed = current_paint_frame_count != active_frame_count_;
...@@ -82,8 +82,8 @@ int PaintWorklet::GetPaintsBeforeSwitching() { ...@@ -82,8 +82,8 @@ int PaintWorklet::GetPaintsBeforeSwitching() {
return base::RandInt(0, kMaxPaintCountToSwitch - 1); return base::RandInt(0, kMaxPaintCountToSwitch - 1);
} }
size_t PaintWorklet::SelectNewGlobalScope() { wtf_size_t PaintWorklet::SelectNewGlobalScope() {
return static_cast<size_t>(base::RandGenerator(kNumGlobalScopes)); return static_cast<wtf_size_t>(base::RandGenerator(kNumGlobalScopes));
} }
scoped_refptr<Image> PaintWorklet::Paint(const String& name, scoped_refptr<Image> PaintWorklet::Paint(const String& name,
......
...@@ -29,7 +29,7 @@ class MODULES_EXPORT PaintWorklet : public Worklet, ...@@ -29,7 +29,7 @@ class MODULES_EXPORT PaintWorklet : public Worklet,
static const char kSupplementName[]; static const char kSupplementName[];
// At this moment, paint worklet allows at most two global scopes at any time. // At this moment, paint worklet allows at most two global scopes at any time.
static const size_t kNumGlobalScopes; static const wtf_size_t kNumGlobalScopes;
static PaintWorklet* From(LocalDOMWindow&); static PaintWorklet* From(LocalDOMWindow&);
static PaintWorklet* Create(LocalFrame*); static PaintWorklet* Create(LocalFrame*);
...@@ -54,8 +54,8 @@ class MODULES_EXPORT PaintWorklet : public Worklet, ...@@ -54,8 +54,8 @@ class MODULES_EXPORT PaintWorklet : public Worklet,
// Since paint worklet has more than one global scope, we MUST override this // Since paint worklet has more than one global scope, we MUST override this
// function and provide our own selection logic. // function and provide our own selection logic.
size_t SelectGlobalScope() final; wtf_size_t SelectGlobalScope() final;
size_t GetActiveGlobalScopeForTesting() { return active_global_scope_; } wtf_size_t GetActiveGlobalScopeForTesting() { return active_global_scope_; }
private: private:
friend class PaintWorkletTest; friend class PaintWorkletTest;
...@@ -68,7 +68,7 @@ class MODULES_EXPORT PaintWorklet : public Worklet, ...@@ -68,7 +68,7 @@ class MODULES_EXPORT PaintWorklet : public Worklet,
// global scopes. // global scopes.
virtual int GetPaintsBeforeSwitching(); virtual int GetPaintsBeforeSwitching();
// This function calculates the next global scope to switch to. // This function calculates the next global scope to switch to.
virtual size_t SelectNewGlobalScope(); virtual wtf_size_t SelectNewGlobalScope();
Member<PaintWorkletPendingGeneratorRegistry> pending_generator_registry_; Member<PaintWorkletPendingGeneratorRegistry> pending_generator_registry_;
DocumentDefinitionMap document_definition_map_; DocumentDefinitionMap document_definition_map_;
...@@ -77,7 +77,7 @@ class MODULES_EXPORT PaintWorklet : public Worklet, ...@@ -77,7 +77,7 @@ class MODULES_EXPORT PaintWorklet : public Worklet,
// tell when we begin painting on a new frame. // tell when we begin painting on a new frame.
size_t active_frame_count_ = 0u; size_t active_frame_count_ = 0u;
// The current global scope being used for painting. // The current global scope being used for painting.
size_t active_global_scope_ = 0u; wtf_size_t active_global_scope_ = 0u;
// The number of paint calls remaining before Paint will select a new global // The number of paint calls remaining before Paint will select a new global
// scope. SelectGlobalScope resets this at the beginning of each frame. // scope. SelectGlobalScope resets this at the beginning of each frame.
int paints_before_switching_global_scope_; int paints_before_switching_global_scope_;
......
...@@ -23,13 +23,13 @@ class TestPaintWorklet : public PaintWorklet { ...@@ -23,13 +23,13 @@ class TestPaintWorklet : public PaintWorklet {
public: public:
explicit TestPaintWorklet(LocalFrame* frame) : PaintWorklet(frame) {} explicit TestPaintWorklet(LocalFrame* frame) : PaintWorklet(frame) {}
void SetPaintsToSwitch(size_t num) { paints_to_switch_ = num; } void SetPaintsToSwitch(int num) { paints_to_switch_ = num; }
int GetPaintsBeforeSwitching() override { return paints_to_switch_; } int GetPaintsBeforeSwitching() override { return paints_to_switch_; }
// We always switch to another global scope so that we can tell how often it // We always switch to another global scope so that we can tell how often it
// was switched in the test. // was switched in the test.
size_t SelectNewGlobalScope() override { wtf_size_t SelectNewGlobalScope() override {
return (GetActiveGlobalScopeForTesting() + 1) % return (GetActiveGlobalScopeForTesting() + 1) %
PaintWorklet::kNumGlobalScopes; PaintWorklet::kNumGlobalScopes;
} }
...@@ -37,7 +37,7 @@ class TestPaintWorklet : public PaintWorklet { ...@@ -37,7 +37,7 @@ class TestPaintWorklet : public PaintWorklet {
size_t GetActiveGlobalScope() { return GetActiveGlobalScopeForTesting(); } size_t GetActiveGlobalScope() { return GetActiveGlobalScopeForTesting(); }
private: private:
size_t paints_to_switch_; int paints_to_switch_;
}; };
class PaintWorkletTest : public PageTestBase { class PaintWorkletTest : public PageTestBase {
...@@ -66,7 +66,7 @@ class PaintWorkletTest : public PageTestBase { ...@@ -66,7 +66,7 @@ class PaintWorkletTest : public PageTestBase {
// Helper function used in GlobalScopeSelection test. // Helper function used in GlobalScopeSelection test.
void ExpectSwitchGlobalScope(bool expect_switch_within_frame, void ExpectSwitchGlobalScope(bool expect_switch_within_frame,
size_t num_paint_calls, size_t num_paint_calls,
size_t paint_cnt_to_switch, int paint_cnt_to_switch,
size_t expected_num_paints_before_switch, size_t expected_num_paints_before_switch,
TestPaintWorklet* paint_worklet_to_test) { TestPaintWorklet* paint_worklet_to_test) {
paint_worklet_to_test->GetFrame()->View()->UpdateAllLifecyclePhases(); paint_worklet_to_test->GetFrame()->View()->UpdateAllLifecyclePhases();
......
...@@ -45,7 +45,7 @@ constexpr int kMaxDepth = 4; ...@@ -45,7 +45,7 @@ constexpr int kMaxDepth = 4;
// Some strings are very long, and we don't currently use those, so limit string // Some strings are very long, and we don't currently use those, so limit string
// length to something reasonable to avoid undue pressure on Icing. Note that // length to something reasonable to avoid undue pressure on Icing. Note that
// App Indexing supports strings up to length 20k. // App Indexing supports strings up to length 20k.
constexpr int kMaxStringLength = 200; constexpr wtf_size_t kMaxStringLength = 200;
// Enforced by App Indexing, so stop processing early if possible. // Enforced by App Indexing, so stop processing early if possible.
constexpr wtf_size_t kMaxNumFields = 20; constexpr wtf_size_t kMaxNumFields = 20;
// Enforced by App Indexing, so stop processing early if possible. // Enforced by App Indexing, so stop processing early if possible.
...@@ -231,7 +231,7 @@ void extractTopLevelEntity(const JSONObject& val, Vector<EntityPtr>& entities) { ...@@ -231,7 +231,7 @@ void extractTopLevelEntity(const JSONObject& val, Vector<EntityPtr>& entities) {
void extractEntitiesFromArray(const JSONArray& arr, void extractEntitiesFromArray(const JSONArray& arr,
Vector<EntityPtr>& entities) { Vector<EntityPtr>& entities) {
for (size_t i = 0; i < arr.size(); ++i) { for (wtf_size_t i = 0; i < arr.size(); ++i) {
const JSONValue* val = arr.at(i); const JSONValue* val = arr.at(i);
if (val->GetType() == JSONValue::ValueType::kTypeObject) { if (val->GetType() == JSONValue::ValueType::kTypeObject) {
extractTopLevelEntity(*(JSONObject::Cast(val)), entities); extractTopLevelEntity(*(JSONObject::Cast(val)), entities);
......
...@@ -83,18 +83,18 @@ String TextDecoder::decode(const BufferSource& input, ...@@ -83,18 +83,18 @@ String TextDecoder::decode(const BufferSource& input,
if (input.IsArrayBufferView()) { if (input.IsArrayBufferView()) {
const char* start = static_cast<const char*>( const char* start = static_cast<const char*>(
input.GetAsArrayBufferView().View()->BaseAddress()); input.GetAsArrayBufferView().View()->BaseAddress());
size_t length = input.GetAsArrayBufferView().View()->byteLength(); uint32_t length = input.GetAsArrayBufferView().View()->byteLength();
return decode(start, length, options, exception_state); return decode(start, length, options, exception_state);
} }
DCHECK(input.IsArrayBuffer()); DCHECK(input.IsArrayBuffer());
const char* start = const char* start =
static_cast<const char*>(input.GetAsArrayBuffer()->Data()); static_cast<const char*>(input.GetAsArrayBuffer()->Data());
size_t length = input.GetAsArrayBuffer()->ByteLength(); uint32_t length = input.GetAsArrayBuffer()->ByteLength();
return decode(start, length, options, exception_state); return decode(start, length, options, exception_state);
} }
String TextDecoder::decode(const char* start, String TextDecoder::decode(const char* start,
size_t length, uint32_t length,
const TextDecodeOptions& options, const TextDecodeOptions& options,
ExceptionState& exception_state) { ExceptionState& exception_state) {
WTF::FlushBehavior flush = WTF::FlushBehavior flush =
......
...@@ -67,7 +67,7 @@ class TextDecoder final : public ScriptWrappable { ...@@ -67,7 +67,7 @@ class TextDecoder final : public ScriptWrappable {
TextDecoder(const WTF::TextEncoding&, bool fatal, bool ignore_bom); TextDecoder(const WTF::TextEncoding&, bool fatal, bool ignore_bom);
String decode(const char* start, String decode(const char* start,
size_t length, uint32_t length,
const TextDecodeOptions&, const TextDecodeOptions&,
ExceptionState&); ExceptionState&);
......
...@@ -60,7 +60,7 @@ class TextDecoderStream::Transformer final : public TransformStreamTransformer { ...@@ -60,7 +60,7 @@ class TextDecoderStream::Transformer final : public TransformStreamTransformer {
return; return;
} }
const char* start = static_cast<const char*>(view->BaseAddress()); const char* start = static_cast<const char*>(view->BaseAddress());
size_t length = view->byteLength(); uint32_t length = view->byteLength();
DecodeAndEnqueue(start, length, WTF::FlushBehavior::kDoNotFlush, DecodeAndEnqueue(start, length, WTF::FlushBehavior::kDoNotFlush,
controller, exception_state); controller, exception_state);
return; return;
...@@ -74,7 +74,7 @@ class TextDecoderStream::Transformer final : public TransformStreamTransformer { ...@@ -74,7 +74,7 @@ class TextDecoderStream::Transformer final : public TransformStreamTransformer {
return; return;
} }
const char* start = static_cast<const char*>(array_buffer->Data()); const char* start = static_cast<const char*>(array_buffer->Data());
size_t length = array_buffer->ByteLength(); uint32_t length = array_buffer->ByteLength();
DecodeAndEnqueue(start, length, WTF::FlushBehavior::kDoNotFlush, controller, DecodeAndEnqueue(start, length, WTF::FlushBehavior::kDoNotFlush, controller,
exception_state); exception_state);
} }
...@@ -95,7 +95,7 @@ class TextDecoderStream::Transformer final : public TransformStreamTransformer { ...@@ -95,7 +95,7 @@ class TextDecoderStream::Transformer final : public TransformStreamTransformer {
// Implements the second part of "decode and enqueue a chunk" as well as the // Implements the second part of "decode and enqueue a chunk" as well as the
// "flush and enqueue" algorithm. // "flush and enqueue" algorithm.
void DecodeAndEnqueue(const char* start, void DecodeAndEnqueue(const char* start,
size_t length, uint32_t length,
WTF::FlushBehavior flush, WTF::FlushBehavior flush,
TransformStreamDefaultController* controller, TransformStreamDefaultController* controller,
ExceptionState& exception_state) { ExceptionState& exception_state) {
......
...@@ -101,8 +101,8 @@ class TextEncoderStream::Transformer final : public TransformStreamTransformer { ...@@ -101,8 +101,8 @@ class TextEncoderStream::Transformer final : public TransformStreamTransformer {
static DOMUint8Array* CreateDOMUint8ArrayFromTwoCStringsConcatenated( static DOMUint8Array* CreateDOMUint8ArrayFromTwoCStringsConcatenated(
const CString& string1, const CString& string1,
const CString& string2) { const CString& string2) {
const size_t length1 = string1.length(); const wtf_size_t length1 = string1.length();
const size_t length2 = string2.length(); const wtf_size_t length2 = string2.length();
DOMUint8Array* const array = DOMUint8Array::Create(length1 + length2); DOMUint8Array* const array = DOMUint8Array::Create(length1 + length2);
if (length1 > 0) if (length1 > 0)
memcpy(array->Data(), string1.data(), length1); memcpy(array->Data(), string1.data(), length1);
...@@ -144,8 +144,8 @@ class TextEncoderStream::Transformer final : public TransformStreamTransformer { ...@@ -144,8 +144,8 @@ class TextEncoderStream::Transformer final : public TransformStreamTransformer {
} }
// Third argument is ignored, as above. // Third argument is ignored, as above.
*result = *result = encoder_->Encode(begin, static_cast<wtf_size_t>(end - begin),
encoder_->Encode(begin, end - begin, WTF::kEntitiesForUnencodables); WTF::kEntitiesForUnencodables);
DCHECK_NE(result->length(), 0u); DCHECK_NE(result->length(), 0u);
return true; return true;
} }
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "third_party/blink/renderer/platform/network/mime/content_type.h" #include "third_party/blink/renderer/platform/network/mime/content_type.h"
#include "third_party/blink/renderer/platform/timer.h" #include "third_party/blink/renderer/platform/timer.h"
#include "third_party/blink/renderer/platform/wtf/ascii_ctype.h" #include "third_party/blink/renderer/platform/wtf/ascii_ctype.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#define MEDIA_KEY_SESSION_LOG_LEVEL 3 #define MEDIA_KEY_SESSION_LOG_LEVEL 3
...@@ -895,7 +896,7 @@ void MediaKeySession::Message(MessageType message_type, ...@@ -895,7 +896,7 @@ void MediaKeySession::Message(MessageType message_type,
break; break;
} }
init.setMessage(DOMArrayBuffer::Create(static_cast<const void*>(message), init.setMessage(DOMArrayBuffer::Create(static_cast<const void*>(message),
message_length)); SafeCast<uint32_t>(message_length)));
MediaKeyMessageEvent* event = MediaKeyMessageEvent* event =
MediaKeyMessageEvent::Create(EventTypeNames::message, init); MediaKeyMessageEvent::Create(EventTypeNames::message, init);
......
...@@ -100,7 +100,7 @@ class MapIterationSource final ...@@ -100,7 +100,7 @@ class MapIterationSource final
// m_map is stored just for keeping it alive. It needs to be kept // m_map is stored just for keeping it alive. It needs to be kept
// alive while JavaScript holds the iterator to it. // alive while JavaScript holds the iterator to it.
const Member<const MediaKeyStatusMap> map_; const Member<const MediaKeyStatusMap> map_;
size_t current_; uint32_t current_;
}; };
void MediaKeyStatusMap::Clear() { void MediaKeyStatusMap::Clear() {
...@@ -110,20 +110,20 @@ void MediaKeyStatusMap::Clear() { ...@@ -110,20 +110,20 @@ void MediaKeyStatusMap::Clear() {
void MediaKeyStatusMap::AddEntry(WebData key_id, const String& status) { void MediaKeyStatusMap::AddEntry(WebData key_id, const String& status) {
// Insert new entry into sorted list. // Insert new entry into sorted list.
MapEntry* entry = MapEntry::Create(key_id, status); MapEntry* entry = MapEntry::Create(key_id, status);
size_t index = 0; uint32_t index = 0;
while (index < entries_.size() && while (index < entries_.size() &&
MapEntry::CompareLessThan(entries_[index], entry)) MapEntry::CompareLessThan(entries_[index], entry))
++index; ++index;
entries_.insert(index, entry); entries_.insert(index, entry);
} }
const MediaKeyStatusMap::MapEntry& MediaKeyStatusMap::at(size_t index) const { const MediaKeyStatusMap::MapEntry& MediaKeyStatusMap::at(uint32_t index) const {
DCHECK_LT(index, entries_.size()); DCHECK_LT(index, entries_.size());
return *entries_.at(index); return *entries_.at(index);
} }
size_t MediaKeyStatusMap::IndexOf(const DOMArrayPiece& key) const { uint32_t MediaKeyStatusMap::IndexOf(const DOMArrayPiece& key) const {
for (size_t index = 0; index < entries_.size(); ++index) { for (uint32_t index = 0; index < entries_.size(); ++index) {
auto* const current = entries_.at(index)->KeyId(); auto* const current = entries_.at(index)->KeyId();
if (key == *current) if (key == *current)
return index; return index;
...@@ -131,17 +131,17 @@ size_t MediaKeyStatusMap::IndexOf(const DOMArrayPiece& key) const { ...@@ -131,17 +131,17 @@ size_t MediaKeyStatusMap::IndexOf(const DOMArrayPiece& key) const {
// Not found, so return an index outside the valid range. The caller // Not found, so return an index outside the valid range. The caller
// must ensure this value is not exposed outside this class. // must ensure this value is not exposed outside this class.
return std::numeric_limits<size_t>::max(); return std::numeric_limits<uint32_t>::max();
} }
bool MediaKeyStatusMap::has(const ArrayBufferOrArrayBufferView& key_id) { bool MediaKeyStatusMap::has(const ArrayBufferOrArrayBufferView& key_id) {
size_t index = IndexOf(key_id); uint32_t index = IndexOf(key_id);
return index < entries_.size(); return index < entries_.size();
} }
ScriptValue MediaKeyStatusMap::get(ScriptState* script_state, ScriptValue MediaKeyStatusMap::get(ScriptState* script_state,
const ArrayBufferOrArrayBufferView& key_id) { const ArrayBufferOrArrayBufferView& key_id) {
size_t index = IndexOf(key_id); uint32_t index = IndexOf(key_id);
if (index >= entries_.size()) if (index >= entries_.size())
return ScriptValue(script_state, v8::Undefined(script_state->GetIsolate())); return ScriptValue(script_state, v8::Undefined(script_state->GetIsolate()));
return ScriptValue::From(script_state, at(index).Status()); return ScriptValue::From(script_state, at(index).Status());
......
...@@ -39,10 +39,10 @@ class MediaKeyStatusMap final ...@@ -39,10 +39,10 @@ class MediaKeyStatusMap final
void Clear(); void Clear();
void AddEntry(WebData key_id, const String& status); void AddEntry(WebData key_id, const String& status);
const MapEntry& at(size_t) const; const MapEntry& at(uint32_t) const;
// IDL attributes / methods // IDL attributes / methods
size_t size() const { return entries_.size(); } uint32_t size() const { return entries_.size(); }
bool has(const ArrayBufferOrArrayBufferView& key_id); bool has(const ArrayBufferOrArrayBufferView& key_id);
ScriptValue get(ScriptState*, const ArrayBufferOrArrayBufferView& key_id); ScriptValue get(ScriptState*, const ArrayBufferOrArrayBufferView& key_id);
...@@ -52,7 +52,7 @@ class MediaKeyStatusMap final ...@@ -52,7 +52,7 @@ class MediaKeyStatusMap final
// PairIterable<> implementation. // PairIterable<> implementation.
IterationSource* StartIteration(ScriptState*, ExceptionState&) override; IterationSource* StartIteration(ScriptState*, ExceptionState&) override;
size_t IndexOf(const DOMArrayPiece& key_id) const; uint32_t IndexOf(const DOMArrayPiece& key_id) const;
MediaKeyStatusMapType entries_; MediaKeyStatusMapType entries_;
}; };
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "third_party/blink/renderer/modules/encryptedmedia/media_keys_controller.h" #include "third_party/blink/renderer/modules/encryptedmedia/media_keys_controller.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/timer.h" #include "third_party/blink/renderer/platform/timer.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
namespace blink { namespace blink {
...@@ -70,8 +71,8 @@ class NewCdmResultPromise : public ContentDecryptionModuleResultPromise { ...@@ -70,8 +71,8 @@ class NewCdmResultPromise : public ContentDecryptionModuleResultPromise {
// NavigatorRequestMediaKeySystemAccess. // NavigatorRequestMediaKeySystemAccess.
static Vector<String> ConvertInitDataTypes( static Vector<String> ConvertInitDataTypes(
const WebVector<WebEncryptedMediaInitDataType>& init_data_types) { const WebVector<WebEncryptedMediaInitDataType>& init_data_types) {
Vector<String> result(init_data_types.size()); Vector<String> result(SafeCast<wtf_size_t>(init_data_types.size()));
for (size_t i = 0; i < init_data_types.size(); i++) for (wtf_size_t i = 0; i < result.size(); i++)
result[i] = result[i] =
EncryptedMediaUtils::ConvertFromInitDataType(init_data_types[i]); EncryptedMediaUtils::ConvertFromInitDataType(init_data_types[i]);
return result; return result;
...@@ -79,8 +80,9 @@ static Vector<String> ConvertInitDataTypes( ...@@ -79,8 +80,9 @@ static Vector<String> ConvertInitDataTypes(
static HeapVector<MediaKeySystemMediaCapability> ConvertCapabilities( static HeapVector<MediaKeySystemMediaCapability> ConvertCapabilities(
const WebVector<WebMediaKeySystemMediaCapability>& capabilities) { const WebVector<WebMediaKeySystemMediaCapability>& capabilities) {
HeapVector<MediaKeySystemMediaCapability> result(capabilities.size()); HeapVector<MediaKeySystemMediaCapability> result(
for (size_t i = 0; i < capabilities.size(); i++) { SafeCast<wtf_size_t>(capabilities.size()));
for (wtf_size_t i = 0; i < result.size(); i++) {
MediaKeySystemMediaCapability capability; MediaKeySystemMediaCapability capability;
capability.setContentType(capabilities[i].content_type); capability.setContentType(capabilities[i].content_type);
capability.setRobustness(capabilities[i].robustness); capability.setRobustness(capabilities[i].robustness);
...@@ -119,8 +121,8 @@ static String ConvertMediaKeysRequirement( ...@@ -119,8 +121,8 @@ static String ConvertMediaKeysRequirement(
static Vector<String> ConvertSessionTypes( static Vector<String> ConvertSessionTypes(
const WebVector<WebEncryptedMediaSessionType>& session_types) { const WebVector<WebEncryptedMediaSessionType>& session_types) {
Vector<String> result(session_types.size()); Vector<String> result(SafeCast<wtf_size_t>(session_types.size()));
for (size_t i = 0; i < session_types.size(); i++) for (wtf_size_t i = 0; i < result.size(); i++)
result[i] = EncryptedMediaUtils::ConvertFromSessionType(session_types[i]); result[i] = EncryptedMediaUtils::ConvertFromSessionType(session_types[i]);
return result; return result;
} }
......
...@@ -47,7 +47,7 @@ const char kEncryptedMediaFeaturePolicyConsoleWarning[] = ...@@ -47,7 +47,7 @@ const char kEncryptedMediaFeaturePolicyConsoleWarning[] =
static WebVector<WebEncryptedMediaInitDataType> ConvertInitDataTypes( static WebVector<WebEncryptedMediaInitDataType> ConvertInitDataTypes(
const Vector<String>& init_data_types) { const Vector<String>& init_data_types) {
WebVector<WebEncryptedMediaInitDataType> result(init_data_types.size()); WebVector<WebEncryptedMediaInitDataType> result(init_data_types.size());
for (size_t i = 0; i < init_data_types.size(); ++i) for (wtf_size_t i = 0; i < init_data_types.size(); ++i)
result[i] = EncryptedMediaUtils::ConvertToInitDataType(init_data_types[i]); result[i] = EncryptedMediaUtils::ConvertToInitDataType(init_data_types[i]);
return result; return result;
} }
...@@ -66,7 +66,7 @@ ConvertEncryptionScheme(const String& encryption_scheme) { ...@@ -66,7 +66,7 @@ ConvertEncryptionScheme(const String& encryption_scheme) {
static WebVector<WebMediaKeySystemMediaCapability> ConvertCapabilities( static WebVector<WebMediaKeySystemMediaCapability> ConvertCapabilities(
const HeapVector<MediaKeySystemMediaCapability>& capabilities) { const HeapVector<MediaKeySystemMediaCapability>& capabilities) {
WebVector<WebMediaKeySystemMediaCapability> result(capabilities.size()); WebVector<WebMediaKeySystemMediaCapability> result(capabilities.size());
for (size_t i = 0; i < capabilities.size(); ++i) { for (wtf_size_t i = 0; i < capabilities.size(); ++i) {
const WebString& content_type = capabilities[i].contentType(); const WebString& content_type = capabilities[i].contentType();
result[i].content_type = content_type; result[i].content_type = content_type;
ParsedContentType type(content_type); ParsedContentType type(content_type);
...@@ -115,7 +115,7 @@ static WebMediaKeySystemConfiguration::Requirement ConvertMediaKeysRequirement( ...@@ -115,7 +115,7 @@ static WebMediaKeySystemConfiguration::Requirement ConvertMediaKeysRequirement(
static WebVector<WebEncryptedMediaSessionType> ConvertSessionTypes( static WebVector<WebEncryptedMediaSessionType> ConvertSessionTypes(
const Vector<String>& session_types) { const Vector<String>& session_types) {
WebVector<WebEncryptedMediaSessionType> result(session_types.size()); WebVector<WebEncryptedMediaSessionType> result(session_types.size());
for (size_t i = 0; i < session_types.size(); ++i) for (wtf_size_t i = 0; i < session_types.size(); ++i)
result[i] = EncryptedMediaUtils::ConvertToSessionType(session_types[i]); result[i] = EncryptedMediaUtils::ConvertToSessionType(session_types[i]);
return result; return result;
} }
...@@ -170,7 +170,7 @@ MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer( ...@@ -170,7 +170,7 @@ MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer(
: resolver_(ScriptPromiseResolver::Create(script_state)), : resolver_(ScriptPromiseResolver::Create(script_state)),
key_system_(key_system), key_system_(key_system),
supported_configurations_(supported_configurations.size()) { supported_configurations_(supported_configurations.size()) {
for (size_t i = 0; i < supported_configurations.size(); ++i) { for (wtf_size_t i = 0; i < supported_configurations.size(); ++i) {
const MediaKeySystemConfiguration& config = supported_configurations[i]; const MediaKeySystemConfiguration& config = supported_configurations[i];
WebMediaKeySystemConfiguration web_config; WebMediaKeySystemConfiguration web_config;
......
...@@ -47,8 +47,8 @@ class MODULES_EXPORT MediaRecorder final ...@@ -47,8 +47,8 @@ class MODULES_EXPORT MediaRecorder final
MediaStream* stream() const { return stream_.Get(); } MediaStream* stream() const { return stream_.Get(); }
const String& mimeType() const { return mime_type_; } const String& mimeType() const { return mime_type_; }
String state() const; String state() const;
unsigned long videoBitsPerSecond() const { return video_bits_per_second_; } uint32_t videoBitsPerSecond() const { return video_bits_per_second_; }
unsigned long audioBitsPerSecond() const { return audio_bits_per_second_; } uint32_t audioBitsPerSecond() const { return audio_bits_per_second_; }
DEFINE_ATTRIBUTE_EVENT_LISTENER(start); DEFINE_ATTRIBUTE_EVENT_LISTENER(start);
DEFINE_ATTRIBUTE_EVENT_LISTENER(stop); DEFINE_ATTRIBUTE_EVENT_LISTENER(stop);
......
...@@ -171,7 +171,7 @@ class SourceBuffer final : public EventTargetWithInlineData, ...@@ -171,7 +171,7 @@ class SourceBuffer final : public EventTargetWithInlineData,
bool first_initialization_segment_received_; bool first_initialization_segment_received_;
Vector<unsigned char> pending_append_data_; Vector<unsigned char> pending_append_data_;
size_t pending_append_data_offset_; wtf_size_t pending_append_data_offset_;
Member<AsyncMethodRunner<SourceBuffer>> append_buffer_async_part_runner_; Member<AsyncMethodRunner<SourceBuffer>> append_buffer_async_part_runner_;
double pending_remove_start_; double pending_remove_start_;
......
...@@ -47,13 +47,13 @@ void SourceBufferList::Add(SourceBuffer* buffer) { ...@@ -47,13 +47,13 @@ void SourceBufferList::Add(SourceBuffer* buffer) {
ScheduleEvent(EventTypeNames::addsourcebuffer); ScheduleEvent(EventTypeNames::addsourcebuffer);
} }
void SourceBufferList::insert(size_t position, SourceBuffer* buffer) { void SourceBufferList::insert(wtf_size_t position, SourceBuffer* buffer) {
list_.insert(position, buffer); list_.insert(position, buffer);
ScheduleEvent(EventTypeNames::addsourcebuffer); ScheduleEvent(EventTypeNames::addsourcebuffer);
} }
void SourceBufferList::Remove(SourceBuffer* buffer) { void SourceBufferList::Remove(SourceBuffer* buffer) {
size_t index = list_.Find(buffer); wtf_size_t index = list_.Find(buffer);
if (index == kNotFound) if (index == kNotFound)
return; return;
list_.EraseAt(index); list_.EraseAt(index);
......
...@@ -62,9 +62,9 @@ class SourceBufferList final : public EventTargetWithInlineData, ...@@ -62,9 +62,9 @@ class SourceBufferList final : public EventTargetWithInlineData,
} }
void Add(SourceBuffer*); void Add(SourceBuffer*);
void insert(size_t position, SourceBuffer*); void insert(wtf_size_t position, SourceBuffer*);
void Remove(SourceBuffer*); void Remove(SourceBuffer*);
size_t Find(SourceBuffer* buffer) { return list_.Find(buffer); } wtf_size_t Find(SourceBuffer* buffer) { return list_.Find(buffer); }
bool Contains(SourceBuffer* buffer) { bool Contains(SourceBuffer* buffer) {
return list_.Find(buffer) != kNotFound; return list_.Find(buffer) != kNotFound;
} }
......
...@@ -277,20 +277,21 @@ void MediaDevices::DevicesEnumerated( ...@@ -277,20 +277,21 @@ void MediaDevices::DevicesEnumerated(
return; return;
} }
DCHECK_EQ(static_cast<size_t>(MediaDeviceType::NUM_MEDIA_DEVICE_TYPES), DCHECK_EQ(static_cast<wtf_size_t>(MediaDeviceType::NUM_MEDIA_DEVICE_TYPES),
enumeration.size()); enumeration.size());
if (!video_input_capabilities.IsEmpty()) { if (!video_input_capabilities.IsEmpty()) {
DCHECK_EQ( DCHECK_EQ(
enumeration[static_cast<size_t>(MediaDeviceType::MEDIA_VIDEO_INPUT)] enumeration[static_cast<wtf_size_t>(MediaDeviceType::MEDIA_VIDEO_INPUT)]
.size(), .size(),
video_input_capabilities.size()); video_input_capabilities.size());
} }
MediaDeviceInfoVector media_devices; MediaDeviceInfoVector media_devices;
for (size_t i = 0; for (wtf_size_t i = 0;
i < static_cast<size_t>(MediaDeviceType::NUM_MEDIA_DEVICE_TYPES); ++i) { i < static_cast<wtf_size_t>(MediaDeviceType::NUM_MEDIA_DEVICE_TYPES);
for (size_t j = 0; j < enumeration[i].size(); ++j) { ++i) {
for (wtf_size_t j = 0; j < enumeration[i].size(); ++j) {
MediaDeviceType device_type = static_cast<MediaDeviceType>(i); MediaDeviceType device_type = static_cast<MediaDeviceType>(i);
mojom::blink::MediaDeviceInfoPtr device_info = mojom::blink::MediaDeviceInfoPtr device_info =
std::move(enumeration[i][j]); std::move(enumeration[i][j]);
......
...@@ -223,7 +223,7 @@ class MediaDevicesTest : public testing::Test { ...@@ -223,7 +223,7 @@ class MediaDevicesTest : public testing::Test {
void DevicesEnumerated(const MediaDeviceInfoVector& device_infos) { void DevicesEnumerated(const MediaDeviceInfoVector& device_infos) {
devices_enumerated_ = true; devices_enumerated_ = true;
for (size_t i = 0; i < device_infos.size(); i++) { for (wtf_size_t i = 0; i < device_infos.size(); i++) {
device_infos_->push_back(MediaDeviceInfo::Create( device_infos_->push_back(MediaDeviceInfo::Create(
device_infos[i]->deviceId(), device_infos[i]->label(), device_infos[i]->deviceId(), device_infos[i]->label(),
device_infos[i]->groupId(), device_infos[i]->DeviceType())); device_infos[i]->groupId(), device_infos[i]->DeviceType()));
......
...@@ -38,8 +38,8 @@ namespace blink { ...@@ -38,8 +38,8 @@ namespace blink {
static bool ContainsSource(MediaStreamTrackVector& track_vector, static bool ContainsSource(MediaStreamTrackVector& track_vector,
MediaStreamSource* source) { MediaStreamSource* source) {
for (size_t i = 0; i < track_vector.size(); ++i) { for (MediaStreamTrack* track : track_vector) {
if (source->Id() == track_vector[i]->Component()->Source()->Id()) if (source->Id() == track->Component()->Source()->Id())
return true; return true;
} }
return false; return false;
...@@ -66,11 +66,11 @@ MediaStream* MediaStream::Create(ExecutionContext* context, ...@@ -66,11 +66,11 @@ MediaStream* MediaStream::Create(ExecutionContext* context,
MediaStreamTrackVector audio_tracks; MediaStreamTrackVector audio_tracks;
MediaStreamTrackVector video_tracks; MediaStreamTrackVector video_tracks;
for (size_t i = 0; i < stream->audio_tracks_.size(); ++i) for (MediaStreamTrack* track : stream->audio_tracks_)
ProcessTrack(stream->audio_tracks_[i].Get(), audio_tracks); ProcessTrack(track, audio_tracks);
for (size_t i = 0; i < stream->video_tracks_.size(); ++i) for (MediaStreamTrack* track : stream->video_tracks_)
ProcessTrack(stream->video_tracks_[i].Get(), video_tracks); ProcessTrack(track, video_tracks);
return new MediaStream(context, audio_tracks, video_tracks); return new MediaStream(context, audio_tracks, video_tracks);
} }
...@@ -80,9 +80,9 @@ MediaStream* MediaStream::Create(ExecutionContext* context, ...@@ -80,9 +80,9 @@ MediaStream* MediaStream::Create(ExecutionContext* context,
MediaStreamTrackVector audio_tracks; MediaStreamTrackVector audio_tracks;
MediaStreamTrackVector video_tracks; MediaStreamTrackVector video_tracks;
for (size_t i = 0; i < tracks.size(); ++i) for (MediaStreamTrack* track : tracks) {
ProcessTrack(tracks[i].Get(), ProcessTrack(track, track->kind() == "audio" ? audio_tracks : video_tracks);
tracks[i]->kind() == "audio" ? audio_tracks : video_tracks); }
return new MediaStream(context, audio_tracks, video_tracks); return new MediaStream(context, audio_tracks, video_tracks);
} }
...@@ -110,18 +110,18 @@ MediaStream::MediaStream(ExecutionContext* context, ...@@ -110,18 +110,18 @@ MediaStream::MediaStream(ExecutionContext* context,
&MediaStream::ScheduledEventTimerFired) { &MediaStream::ScheduledEventTimerFired) {
descriptor_->SetClient(this); descriptor_->SetClient(this);
size_t number_of_audio_tracks = descriptor_->NumberOfAudioComponents(); uint32_t number_of_audio_tracks = descriptor_->NumberOfAudioComponents();
audio_tracks_.ReserveCapacity(number_of_audio_tracks); audio_tracks_.ReserveCapacity(number_of_audio_tracks);
for (size_t i = 0; i < number_of_audio_tracks; i++) { for (uint32_t i = 0; i < number_of_audio_tracks; i++) {
MediaStreamTrack* new_track = MediaStreamTrack* new_track =
MediaStreamTrack::Create(context, descriptor_->AudioComponent(i)); MediaStreamTrack::Create(context, descriptor_->AudioComponent(i));
new_track->RegisterMediaStream(this); new_track->RegisterMediaStream(this);
audio_tracks_.push_back(new_track); audio_tracks_.push_back(new_track);
} }
size_t number_of_video_tracks = descriptor_->NumberOfVideoComponents(); uint32_t number_of_video_tracks = descriptor_->NumberOfVideoComponents();
video_tracks_.ReserveCapacity(number_of_video_tracks); video_tracks_.ReserveCapacity(number_of_video_tracks);
for (size_t i = 0; i < number_of_video_tracks; i++) { for (uint32_t i = 0; i < number_of_video_tracks; i++) {
MediaStreamTrack* new_track = MediaStreamTrack* new_track =
MediaStreamTrack::Create(context, descriptor_->VideoComponent(i)); MediaStreamTrack::Create(context, descriptor_->VideoComponent(i));
new_track->RegisterMediaStream(this); new_track->RegisterMediaStream(this);
...@@ -146,15 +146,13 @@ MediaStream::MediaStream(ExecutionContext* context, ...@@ -146,15 +146,13 @@ MediaStream::MediaStream(ExecutionContext* context,
descriptor_->SetClient(this); descriptor_->SetClient(this);
audio_tracks_.ReserveCapacity(audio_tracks.size()); audio_tracks_.ReserveCapacity(audio_tracks.size());
for (size_t i = 0; i < audio_tracks.size(); ++i) { for (MediaStreamTrack* audio_track : audio_tracks) {
MediaStreamTrack* audio_track = audio_tracks[i];
DCHECK_EQ("audio", audio_track->kind()); DCHECK_EQ("audio", audio_track->kind());
audio_track->RegisterMediaStream(this); audio_track->RegisterMediaStream(this);
audio_tracks_.push_back(audio_track); audio_tracks_.push_back(audio_track);
} }
video_tracks_.ReserveCapacity(video_tracks.size()); video_tracks_.ReserveCapacity(video_tracks.size());
for (size_t i = 0; i < video_tracks.size(); ++i) { for (MediaStreamTrack* video_track : video_tracks) {
MediaStreamTrack* video_track = video_tracks[i];
DCHECK_EQ("video", video_track->kind()); DCHECK_EQ("video", video_track->kind());
video_track->RegisterMediaStream(this); video_track->RegisterMediaStream(this);
video_tracks_.push_back(video_track); video_tracks_.push_back(video_track);
...@@ -220,13 +218,13 @@ bool MediaStream::EmptyOrOnlyEndedTracks() { ...@@ -220,13 +218,13 @@ bool MediaStream::EmptyOrOnlyEndedTracks() {
bool MediaStream::TracksMatchDescriptor() { bool MediaStream::TracksMatchDescriptor() {
if (audio_tracks_.size() != descriptor_->NumberOfAudioComponents()) if (audio_tracks_.size() != descriptor_->NumberOfAudioComponents())
return false; return false;
for (size_t i = 0; i < audio_tracks_.size(); i++) { for (wtf_size_t i = 0; i < audio_tracks_.size(); i++) {
if (audio_tracks_[i]->Component() != descriptor_->AudioComponent(i)) if (audio_tracks_[i]->Component() != descriptor_->AudioComponent(i))
return false; return false;
} }
if (video_tracks_.size() != descriptor_->NumberOfVideoComponents()) if (video_tracks_.size() != descriptor_->NumberOfVideoComponents())
return false; return false;
for (size_t i = 0; i < video_tracks_.size(); i++) { for (wtf_size_t i = 0; i < video_tracks_.size(); i++) {
if (video_tracks_[i]->Component() != descriptor_->VideoComponent(i)) if (video_tracks_[i]->Component() != descriptor_->VideoComponent(i))
return false; return false;
} }
...@@ -285,7 +283,7 @@ void MediaStream::removeTrack(MediaStreamTrack* track, ...@@ -285,7 +283,7 @@ void MediaStream::removeTrack(MediaStreamTrack* track,
return; return;
} }
size_t pos = kNotFound; wtf_size_t pos = kNotFound;
switch (track->Component()->Source()->GetType()) { switch (track->Component()->Source()->GetType()) {
case MediaStreamSource::kTypeAudio: case MediaStreamSource::kTypeAudio:
pos = audio_tracks_.Find(track); pos = audio_tracks_.Find(track);
...@@ -421,8 +419,8 @@ void MediaStream::RemoveTrackByComponentAndFireEvents( ...@@ -421,8 +419,8 @@ void MediaStream::RemoveTrackByComponentAndFireEvents(
break; break;
} }
size_t index = kNotFound; wtf_size_t index = kNotFound;
for (size_t i = 0; i < tracks->size(); ++i) { for (wtf_size_t i = 0; i < tracks->size(); ++i) {
if ((*tracks)[i]->Component() == component) { if ((*tracks)[i]->Component() == component) {
index = i; index = i;
break; break;
......
...@@ -84,10 +84,10 @@ SkBitmap NotificationImageLoader::ScaleDownIfNeeded(const SkBitmap& image, ...@@ -84,10 +84,10 @@ SkBitmap NotificationImageLoader::ScaleDownIfNeeded(const SkBitmap& image,
static_cast<double>(max_height_px) / image.height()); static_cast<double>(max_height_px) / image.height());
TimeTicks start_time = CurrentTimeTicks(); TimeTicks start_time = CurrentTimeTicks();
// TODO(peter): Try using RESIZE_BETTER for large images. // TODO(peter): Try using RESIZE_BETTER for large images.
SkBitmap scaled_image = SkBitmap scaled_image = skia::ImageOperations::Resize(
skia::ImageOperations::Resize(image, skia::ImageOperations::RESIZE_BEST, image, skia::ImageOperations::RESIZE_BEST,
std::lround(scale * image.width()), static_cast<int>(std::lround(scale * image.width())),
std::lround(scale * image.height())); static_cast<int>(std::lround(scale * image.height())));
NOTIFICATION_HISTOGRAM_COUNTS( NOTIFICATION_HISTOGRAM_COUNTS(
LoadScaleDownTime, type, LoadScaleDownTime, type,
base::saturated_cast<base::HistogramBase::Sample>( base::saturated_cast<base::HistogramBase::Sample>(
...@@ -155,8 +155,10 @@ void NotificationImageLoader::DidFinishLoading( ...@@ -155,8 +155,10 @@ void NotificationImageLoader::DidFinishLoading(
1000 * 60 * 60 /* 1 hour max */); 1000 * 60 * 60 /* 1 hour max */);
if (data_) { if (data_) {
NOTIFICATION_HISTOGRAM_COUNTS(LoadFileSize, type_, data_->size(), NOTIFICATION_HISTOGRAM_COUNTS(
10000000 /* ~10mb max */); LoadFileSize, type_,
base::saturated_cast<base::HistogramBase::Sample>(data_->size()),
10000000 /* ~10mb max */);
const bool data_complete = true; const bool data_complete = true;
std::unique_ptr<ImageDecoder> decoder = ImageDecoder::Create( std::unique_ptr<ImageDecoder> decoder = ImageDecoder::Create(
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/modules/notifications/notification_manager.h" #include "third_party/blink/renderer/modules/notifications/notification_manager.h"
#include "base/numerics/safe_conversions.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/mojom/notifications/notification.mojom-blink.h" #include "third_party/blink/public/mojom/notifications/notification.mojom-blink.h"
#include "third_party/blink/public/platform/interface_provider.h" #include "third_party/blink/public/platform/interface_provider.h"
...@@ -155,7 +156,8 @@ void NotificationManager::DisplayPersistentNotification( ...@@ -155,7 +156,8 @@ void NotificationManager::DisplayPersistentNotification(
DEFINE_THREAD_SAFE_STATIC_LOCAL( DEFINE_THREAD_SAFE_STATIC_LOCAL(
CustomCountHistogram, notification_data_size_histogram, CustomCountHistogram, notification_data_size_histogram,
("Notifications.AuthorDataSize", 1, 1000, 50)); ("Notifications.AuthorDataSize", 1, 1000, 50));
notification_data_size_histogram.Count(author_data_size); notification_data_size_histogram.Count(
base::saturated_cast<base::HistogramBase::Sample>(author_data_size));
if (author_data_size > if (author_data_size >
mojom::blink::NotificationData::kMaximumDeveloperDataSize) { mojom::blink::NotificationData::kMaximumDeveloperDataSize) {
...@@ -210,7 +212,7 @@ void NotificationManager::DidGetNotifications( ...@@ -210,7 +212,7 @@ void NotificationManager::DidGetNotifications(
HeapVector<Member<Notification>> notifications; HeapVector<Member<Notification>> notifications;
notifications.ReserveInitialCapacity(notification_ids.size()); notifications.ReserveInitialCapacity(notification_ids.size());
for (size_t i = 0; i < notification_ids.size(); ++i) { for (wtf_size_t i = 0; i < notification_ids.size(); ++i) {
notifications.push_back(Notification::Create( notifications.push_back(Notification::Create(
resolver->GetExecutionContext(), notification_ids[i], resolver->GetExecutionContext(), notification_ids[i],
std::move(notification_datas[i]), true /* showing */)); std::move(notification_datas[i]), true /* showing */));
......
...@@ -29,9 +29,9 @@ void NotificationResourcesLoader::Start( ...@@ -29,9 +29,9 @@ void NotificationResourcesLoader::Start(
DCHECK(!started_); DCHECK(!started_);
started_ = true; started_ = true;
size_t num_actions = notification_data.actions.has_value() wtf_size_t num_actions = notification_data.actions.has_value()
? notification_data.actions->size() ? notification_data.actions->size()
: 0; : 0;
pending_request_count_ = 3 /* image, icon, badge */ + num_actions; pending_request_count_ = 3 /* image, icon, badge */ + num_actions;
// TODO(johnme): ensure image is not loaded when it will not be used. // TODO(johnme): ensure image is not loaded when it will not be used.
...@@ -50,7 +50,7 @@ void NotificationResourcesLoader::Start( ...@@ -50,7 +50,7 @@ void NotificationResourcesLoader::Start(
WrapWeakPersistent(this))); WrapWeakPersistent(this)));
action_icons_.resize(num_actions); action_icons_.resize(num_actions);
for (size_t i = 0; i < num_actions; i++) for (wtf_size_t i = 0; i < num_actions; i++)
LoadImage(context, NotificationImageLoader::Type::kActionIcon, LoadImage(context, NotificationImageLoader::Type::kActionIcon,
notification_data.actions.value()[i]->icon, notification_data.actions.value()[i]->icon,
WTF::Bind(&NotificationResourcesLoader::DidLoadActionIcon, WTF::Bind(&NotificationResourcesLoader::DidLoadActionIcon,
...@@ -109,7 +109,7 @@ void NotificationResourcesLoader::DidLoadBadge(const SkBitmap& image) { ...@@ -109,7 +109,7 @@ void NotificationResourcesLoader::DidLoadBadge(const SkBitmap& image) {
DidFinishRequest(); DidFinishRequest();
} }
void NotificationResourcesLoader::DidLoadActionIcon(size_t action_index, void NotificationResourcesLoader::DidLoadActionIcon(wtf_size_t action_index,
const SkBitmap& image) { const SkBitmap& image) {
DCHECK_LT(action_index, action_icons_.size()); DCHECK_LT(action_index, action_icons_.size());
......
...@@ -63,7 +63,7 @@ class MODULES_EXPORT NotificationResourcesLoader final ...@@ -63,7 +63,7 @@ class MODULES_EXPORT NotificationResourcesLoader final
void DidLoadImage(const SkBitmap& image); void DidLoadImage(const SkBitmap& image);
void DidLoadIcon(const SkBitmap& image); void DidLoadIcon(const SkBitmap& image);
void DidLoadBadge(const SkBitmap& image); void DidLoadBadge(const SkBitmap& image);
void DidLoadActionIcon(size_t action_index, const SkBitmap& image); void DidLoadActionIcon(wtf_size_t action_index, const SkBitmap& image);
// Decrements |m_pendingRequestCount| and runs |m_completionCallback| if // Decrements |m_pendingRequestCount| and runs |m_completionCallback| if
// there are no more pending requests. // there are no more pending requests.
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.h" #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.h"
#include "third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h" #include "third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
namespace blink { namespace blink {
...@@ -164,7 +165,7 @@ String RTCDataChannel::readyState() const { ...@@ -164,7 +165,7 @@ String RTCDataChannel::readyState() const {
} }
unsigned RTCDataChannel::bufferedAmount() const { unsigned RTCDataChannel::bufferedAmount() const {
return handler_->BufferedAmount(); return SafeCast<unsigned>(handler_->BufferedAmount());
} }
unsigned RTCDataChannel::bufferedAmountLowThreshold() const { unsigned RTCDataChannel::bufferedAmountLowThreshold() const {
...@@ -285,7 +286,8 @@ void RTCDataChannel::DidReceiveRawData(const char* data, size_t data_length) { ...@@ -285,7 +286,8 @@ void RTCDataChannel::DidReceiveRawData(const char* data, size_t data_length) {
return; return;
} }
if (binary_type_ == kBinaryTypeArrayBuffer) { if (binary_type_ == kBinaryTypeArrayBuffer) {
DOMArrayBuffer* buffer = DOMArrayBuffer::Create(data, data_length); DOMArrayBuffer* buffer =
DOMArrayBuffer::Create(data, SafeCast<unsigned>(data_length));
ScheduleDispatchEvent(MessageEvent::Create(buffer)); ScheduleDispatchEvent(MessageEvent::Create(buffer));
return; return;
} }
......
...@@ -64,7 +64,8 @@ class MockHandler final : public WebRTCDataChannelHandler { ...@@ -64,7 +64,8 @@ class MockHandler final : public WebRTCDataChannelHandler {
unsigned long old_buffered_amount = buffered_amount_; unsigned long old_buffered_amount = buffered_amount_;
buffered_amount_ -= bytes; buffered_amount_ -= bytes;
if (client_) { if (client_) {
client_->DidDecreaseBufferedAmount(old_buffered_amount); client_->DidDecreaseBufferedAmount(
static_cast<unsigned>(old_buffered_amount));
} }
} }
......
...@@ -113,6 +113,7 @@ ...@@ -113,6 +113,7 @@
#include "third_party/blink/renderer/platform/peerconnection/rtc_answer_options_platform.h" #include "third_party/blink/renderer/platform/peerconnection/rtc_answer_options_platform.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_offer_options_platform.h" #include "third_party/blink/renderer/platform/peerconnection/rtc_offer_options_platform.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/time.h" #include "third_party/blink/renderer/platform/wtf/time.h"
#include "third_party/webrtc/api/jsep.h" #include "third_party/webrtc/api/jsep.h"
#include "third_party/webrtc/api/peerconnectioninterface.h" #include "third_party/webrtc/api/peerconnectioninterface.h"
...@@ -404,7 +405,7 @@ webrtc::PeerConnectionInterface::RTCConfiguration ParseConfiguration( ...@@ -404,7 +405,7 @@ webrtc::PeerConnectionInterface::RTCConfiguration ParseConfiguration(
configuration.certificates(); configuration.certificates();
std::vector<rtc::scoped_refptr<rtc::RTCCertificate>> certificates_copy( std::vector<rtc::scoped_refptr<rtc::RTCCertificate>> certificates_copy(
certificates.size()); certificates.size());
for (size_t i = 0; i < certificates.size(); ++i) { for (wtf_size_t i = 0; i < certificates.size(); ++i) {
certificates_copy[i] = certificates[i]->Certificate(); certificates_copy[i] = certificates[i]->Certificate();
} }
web_configuration.certificates = std::move(certificates_copy); web_configuration.certificates = std::move(certificates_copy);
...@@ -461,22 +462,24 @@ bool FingerprintMismatch(String old_sdp, String new_sdp) { ...@@ -461,22 +462,24 @@ bool FingerprintMismatch(String old_sdp, String new_sdp) {
// It's impossible to generate a valid fingerprint without createOffer // It's impossible to generate a valid fingerprint without createOffer
// or createAnswer, so this only applies when there are no fingerprints. // or createAnswer, so this only applies when there are no fingerprints.
// This is allowed. // This is allowed.
const size_t new_fingerprint_pos = new_sdp.Find("\na=fingerprint:"); const wtf_size_t new_fingerprint_pos = new_sdp.Find("\na=fingerprint:");
if (new_fingerprint_pos == kNotFound) { if (new_fingerprint_pos == kNotFound) {
return false; return false;
} }
// Look for fingerprint having been added. Not allowed. // Look for fingerprint having been added. Not allowed.
const size_t old_fingerprint_pos = old_sdp.Find("\na=fingerprint:"); const wtf_size_t old_fingerprint_pos = old_sdp.Find("\na=fingerprint:");
if (old_fingerprint_pos == kNotFound) { if (old_fingerprint_pos == kNotFound) {
return true; return true;
} }
// Look for fingerprint being modified. Not allowed. Handle differences in // Look for fingerprint being modified. Not allowed. Handle differences in
// line endings ('\r\n' vs, '\n' when looking for the end of the fingerprint). // line endings ('\r\n' vs, '\n' when looking for the end of the fingerprint).
size_t old_fingerprint_end = old_sdp.Find("\r\n", old_fingerprint_pos + 1); wtf_size_t old_fingerprint_end =
old_sdp.Find("\r\n", old_fingerprint_pos + 1);
if (old_fingerprint_end == WTF::kNotFound) { if (old_fingerprint_end == WTF::kNotFound) {
old_fingerprint_end = old_sdp.Find("\n", old_fingerprint_pos + 1); old_fingerprint_end = old_sdp.Find("\n", old_fingerprint_pos + 1);
} }
size_t new_fingerprint_end = new_sdp.Find("\r\n", new_fingerprint_pos + 1); wtf_size_t new_fingerprint_end =
new_sdp.Find("\r\n", new_fingerprint_pos + 1);
if (new_fingerprint_end == WTF::kNotFound) { if (new_fingerprint_end == WTF::kNotFound) {
new_fingerprint_end = new_sdp.Find("\n", new_fingerprint_pos + 1); new_fingerprint_end = new_sdp.Find("\n", new_fingerprint_pos + 1);
} }
...@@ -1116,14 +1119,15 @@ void RTCPeerConnection::getConfiguration(RTCConfiguration& result) { ...@@ -1116,14 +1119,15 @@ void RTCPeerConnection::getConfiguration(RTCConfiguration& result) {
} }
HeapVector<RTCIceServer> ice_servers; HeapVector<RTCIceServer> ice_servers;
ice_servers.ReserveCapacity(webrtc_configuration.servers.size()); ice_servers.ReserveCapacity(
SafeCast<wtf_size_t>(webrtc_configuration.servers.size()));
for (const auto& webrtc_server : webrtc_configuration.servers) { for (const auto& webrtc_server : webrtc_configuration.servers) {
ice_servers.emplace_back(); ice_servers.emplace_back();
auto& ice_server = ice_servers.back(); auto& ice_server = ice_servers.back();
StringOrStringSequence urls; StringOrStringSequence urls;
Vector<String> url_vector; Vector<String> url_vector;
url_vector.ReserveCapacity(webrtc_server.urls.size()); url_vector.ReserveCapacity(SafeCast<wtf_size_t>(webrtc_server.urls.size()));
for (const auto& url : webrtc_server.urls) { for (const auto& url : webrtc_server.urls) {
url_vector.emplace_back(url.c_str()); url_vector.emplace_back(url.c_str());
} }
...@@ -1137,7 +1141,8 @@ void RTCPeerConnection::getConfiguration(RTCConfiguration& result) { ...@@ -1137,7 +1141,8 @@ void RTCPeerConnection::getConfiguration(RTCConfiguration& result) {
if (!webrtc_configuration.certificates.empty()) { if (!webrtc_configuration.certificates.empty()) {
HeapVector<blink::Member<RTCCertificate>> certificates; HeapVector<blink::Member<RTCCertificate>> certificates;
certificates.ReserveCapacity(webrtc_configuration.certificates.size()); certificates.ReserveCapacity(
SafeCast<wtf_size_t>(webrtc_configuration.certificates.size()));
for (const auto& webrtc_certificate : webrtc_configuration.certificates) { for (const auto& webrtc_certificate : webrtc_configuration.certificates) {
certificates.emplace_back(new RTCCertificate(webrtc_certificate)); certificates.emplace_back(new RTCCertificate(webrtc_certificate));
} }
...@@ -1761,7 +1766,7 @@ RTCRtpSender* RTCPeerConnection::addTrack(MediaStreamTrack* track, ...@@ -1761,7 +1766,7 @@ RTCRtpSender* RTCPeerConnection::addTrack(MediaStreamTrack* track,
} }
WebVector<WebMediaStream> web_streams(streams.size()); WebVector<WebMediaStream> web_streams(streams.size());
for (size_t i = 0; i < streams.size(); ++i) { for (wtf_size_t i = 0; i < streams.size(); ++i) {
web_streams[i] = streams[i]->Descriptor(); web_streams[i] = streams[i]->Descriptor();
} }
webrtc::RTCErrorOr<std::unique_ptr<WebRTCRtpTransceiver>> webrtc::RTCErrorOr<std::unique_ptr<WebRTCRtpTransceiver>>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/modules/peerconnection/rtc_rtp_capabilities.h" #include "third_party/blink/renderer/modules/peerconnection/rtc_rtp_capabilities.h"
#include "third_party/blink/renderer/modules/peerconnection/web_rtc_stats_report_callback_resolver.h" #include "third_party/blink/renderer/modules/peerconnection/web_rtc_stats_report_callback_resolver.h"
#include "third_party/blink/renderer/platform/bindings/microtask.h" #include "third_party/blink/renderer/platform/bindings/microtask.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/webrtc/api/rtpparameters.h" #include "third_party/webrtc/api/rtpparameters.h"
...@@ -106,7 +107,8 @@ void RTCRtpReceiver::getCapabilities( ...@@ -106,7 +107,8 @@ void RTCRtpReceiver::getCapabilities(
blink::Platform::Current()->GetRtpSenderCapabilities(kind); blink::Platform::Current()->GetRtpSenderCapabilities(kind);
HeapVector<RTCRtpCodecCapability> codecs; HeapVector<RTCRtpCodecCapability> codecs;
codecs.ReserveInitialCapacity(rtc_capabilities->codecs.size()); codecs.ReserveInitialCapacity(
SafeCast<wtf_size_t>(rtc_capabilities->codecs.size()));
for (const auto& rtc_codec : rtc_capabilities->codecs) { for (const auto& rtc_codec : rtc_capabilities->codecs) {
codecs.emplace_back(); codecs.emplace_back();
auto& codec = codecs.back(); auto& codec = codecs.back();
...@@ -129,7 +131,7 @@ void RTCRtpReceiver::getCapabilities( ...@@ -129,7 +131,7 @@ void RTCRtpReceiver::getCapabilities(
HeapVector<RTCRtpHeaderExtensionCapability> header_extensions; HeapVector<RTCRtpHeaderExtensionCapability> header_extensions;
header_extensions.ReserveInitialCapacity( header_extensions.ReserveInitialCapacity(
rtc_capabilities->header_extensions.size()); SafeCast<wtf_size_t>(rtc_capabilities->header_extensions.size()));
for (const auto& rtc_header_extension : rtc_capabilities->header_extensions) { for (const auto& rtc_header_extension : rtc_capabilities->header_extensions) {
header_extensions.emplace_back(); header_extensions.emplace_back();
auto& header_extension = header_extensions.back(); auto& header_extension = header_extensions.back();
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "third_party/blink/renderer/modules/peerconnection/web_rtc_stats_report_callback_resolver.h" #include "third_party/blink/renderer/modules/peerconnection/web_rtc_stats_report_callback_resolver.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_void_request.h" #include "third_party/blink/renderer/platform/peerconnection/rtc_void_request.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
namespace blink { namespace blink {
...@@ -107,7 +108,7 @@ bool HasInvalidModification(const RTCRtpSendParameters& parameters, ...@@ -107,7 +108,7 @@ bool HasInvalidModification(const RTCRtpSendParameters& parameters,
new_parameters.headerExtensions().size()) new_parameters.headerExtensions().size())
return true; return true;
for (size_t i = 0; i < parameters.headerExtensions().size(); ++i) { for (wtf_size_t i = 0; i < parameters.headerExtensions().size(); ++i) {
const auto& header_extension = parameters.headerExtensions()[i]; const auto& header_extension = parameters.headerExtensions()[i];
const auto& new_header_extension = new_parameters.headerExtensions()[i]; const auto& new_header_extension = new_parameters.headerExtensions()[i];
if (header_extension.hasUri() != new_header_extension.hasUri() || if (header_extension.hasUri() != new_header_extension.hasUri() ||
...@@ -145,7 +146,7 @@ bool HasInvalidModification(const RTCRtpSendParameters& parameters, ...@@ -145,7 +146,7 @@ bool HasInvalidModification(const RTCRtpSendParameters& parameters,
if (parameters.codecs().size() != new_parameters.codecs().size()) if (parameters.codecs().size() != new_parameters.codecs().size())
return true; return true;
for (std::size_t i = 0; i < parameters.codecs().size(); ++i) { for (wtf_size_t i = 0; i < parameters.codecs().size(); ++i) {
const auto& codec = parameters.codecs()[i]; const auto& codec = parameters.codecs()[i];
const auto& new_codec = new_parameters.codecs()[i]; const auto& new_codec = new_parameters.codecs()[i];
if (codec.hasPayloadType() != new_codec.hasPayloadType() || if (codec.hasPayloadType() != new_codec.hasPayloadType() ||
...@@ -300,7 +301,8 @@ void RTCRtpSender::getParameters(RTCRtpSendParameters& parameters) { ...@@ -300,7 +301,8 @@ void RTCRtpSender::getParameters(RTCRtpSendParameters& parameters) {
parameters.setRtcp(rtcp); parameters.setRtcp(rtcp);
HeapVector<RTCRtpEncodingParameters> encodings; HeapVector<RTCRtpEncodingParameters> encodings;
encodings.ReserveCapacity(webrtc_parameters->encodings.size()); encodings.ReserveCapacity(
SafeCast<wtf_size_t>(webrtc_parameters->encodings.size()));
for (const auto& web_encoding : webrtc_parameters->encodings) { for (const auto& web_encoding : webrtc_parameters->encodings) {
// TODO(orphis): Forward missing fields from the WebRTC library: // TODO(orphis): Forward missing fields from the WebRTC library:
// codecPayloadType, dtx, ptime, maxFramerate, scaleResolutionDownBy, rid // codecPayloadType, dtx, ptime, maxFramerate, scaleResolutionDownBy, rid
...@@ -315,7 +317,8 @@ void RTCRtpSender::getParameters(RTCRtpSendParameters& parameters) { ...@@ -315,7 +317,8 @@ void RTCRtpSender::getParameters(RTCRtpSendParameters& parameters) {
parameters.setEncodings(encodings); parameters.setEncodings(encodings);
HeapVector<RTCRtpHeaderExtensionParameters> headers; HeapVector<RTCRtpHeaderExtensionParameters> headers;
headers.ReserveCapacity(webrtc_parameters->header_extensions.size()); headers.ReserveCapacity(
SafeCast<wtf_size_t>(webrtc_parameters->header_extensions.size()));
for (const auto& web_header : webrtc_parameters->header_extensions) { for (const auto& web_header : webrtc_parameters->header_extensions) {
headers.emplace_back(); headers.emplace_back();
RTCRtpHeaderExtensionParameters& header = headers.back(); RTCRtpHeaderExtensionParameters& header = headers.back();
...@@ -326,7 +329,8 @@ void RTCRtpSender::getParameters(RTCRtpSendParameters& parameters) { ...@@ -326,7 +329,8 @@ void RTCRtpSender::getParameters(RTCRtpSendParameters& parameters) {
parameters.setHeaderExtensions(headers); parameters.setHeaderExtensions(headers);
HeapVector<RTCRtpCodecParameters> codecs; HeapVector<RTCRtpCodecParameters> codecs;
codecs.ReserveCapacity(webrtc_parameters->codecs.size()); codecs.ReserveCapacity(
SafeCast<wtf_size_t>(webrtc_parameters->codecs.size()));
for (const auto& web_codec : webrtc_parameters->codecs) { for (const auto& web_codec : webrtc_parameters->codecs) {
codecs.emplace_back(); codecs.emplace_back();
RTCRtpCodecParameters& codec = codecs.back(); RTCRtpCodecParameters& codec = codecs.back();
...@@ -459,7 +463,8 @@ void RTCRtpSender::getCapabilities( ...@@ -459,7 +463,8 @@ void RTCRtpSender::getCapabilities(
blink::Platform::Current()->GetRtpSenderCapabilities(kind); blink::Platform::Current()->GetRtpSenderCapabilities(kind);
HeapVector<RTCRtpCodecCapability> codecs; HeapVector<RTCRtpCodecCapability> codecs;
codecs.ReserveInitialCapacity(rtc_capabilities->codecs.size()); codecs.ReserveInitialCapacity(
SafeCast<wtf_size_t>(rtc_capabilities->codecs.size()));
for (const auto& rtc_codec : rtc_capabilities->codecs) { for (const auto& rtc_codec : rtc_capabilities->codecs) {
codecs.emplace_back(); codecs.emplace_back();
auto& codec = codecs.back(); auto& codec = codecs.back();
...@@ -482,7 +487,7 @@ void RTCRtpSender::getCapabilities( ...@@ -482,7 +487,7 @@ void RTCRtpSender::getCapabilities(
HeapVector<RTCRtpHeaderExtensionCapability> header_extensions; HeapVector<RTCRtpHeaderExtensionCapability> header_extensions;
header_extensions.ReserveInitialCapacity( header_extensions.ReserveInitialCapacity(
rtc_capabilities->header_extensions.size()); SafeCast<wtf_size_t>(rtc_capabilities->header_extensions.size()));
for (const auto& rtc_header_extension : rtc_capabilities->header_extensions) { for (const auto& rtc_header_extension : rtc_capabilities->header_extensions) {
header_extensions.emplace_back(); header_extensions.emplace_back();
auto& header_extension = header_extensions.back(); auto& header_extension = header_extensions.back();
......
...@@ -116,6 +116,10 @@ class RTCStatsReportIterationSource final ...@@ -116,6 +116,10 @@ class RTCStatsReportIterationSource final
RTCStatsReport::RTCStatsReport(std::unique_ptr<WebRTCStatsReport> report) RTCStatsReport::RTCStatsReport(std::unique_ptr<WebRTCStatsReport> report)
: report_(std::move(report)) {} : report_(std::move(report)) {}
uint32_t RTCStatsReport::size() const {
return base::saturated_cast<uint32_t>(report_->Size());
}
PairIterable<String, v8::Local<v8::Value>>::IterationSource* PairIterable<String, v8::Local<v8::Value>>::IterationSource*
RTCStatsReport::StartIteration(ScriptState*, ExceptionState&) { RTCStatsReport::StartIteration(ScriptState*, ExceptionState&) {
return new RTCStatsReportIterationSource(report_->CopyHandle()); return new RTCStatsReportIterationSource(report_->CopyHandle());
......
...@@ -23,7 +23,7 @@ class RTCStatsReport final : public ScriptWrappable, ...@@ -23,7 +23,7 @@ class RTCStatsReport final : public ScriptWrappable,
public: public:
RTCStatsReport(std::unique_ptr<WebRTCStatsReport>); RTCStatsReport(std::unique_ptr<WebRTCStatsReport>);
size_t size() const { return report_->Size(); } uint32_t size() const;
// Maplike<String, v8::Local<v8::Value>> // Maplike<String, v8::Local<v8::Value>>
PairIterable<String, v8::Local<v8::Value>>::IterationSource* StartIteration( PairIterable<String, v8::Local<v8::Value>>::IterationSource* StartIteration(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment