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

Unified Diff: third_party/WebKit/Source/platform/SharedBuffer.h

Issue 2249533003: [Platform] Enable to get a partial data of SharedBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | third_party/WebKit/Source/platform/SharedBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/SharedBuffer.h
diff --git a/third_party/WebKit/Source/platform/SharedBuffer.h b/third_party/WebKit/Source/platform/SharedBuffer.h
index b03aa8582bffa7c1c068ada2c57769052190b0c5..a8d96c043df4899b9a3339bd1ca6851998a4a591 100644
--- a/third_party/WebKit/Source/platform/SharedBuffer.h
+++ b/third_party/WebKit/Source/platform/SharedBuffer.h
@@ -125,7 +125,20 @@ public:
bool getAsBytes(void* dest, STRICTLY_TYPED_ARG(byteLength)) const
{
STRICT_ARG_TYPE(size_t);
- return getAsBytesInternal(dest, byteLength);
+ if (byteLength != size())
+ return false;
+
+ return getAsBytesInternal(dest, 0, byteLength);
+ }
+
+ // Copies "byteLength" bytes from "position"-th bytes (0 origin) of the content
+ // data into "dest" as a flat buffer,
+ // Returns true on success, otherwise the content of "dest" is not guaranteed.
+ HAS_STRICTLY_TYPED_ARG
+ bool getPartAsBytes(void* dest, STRICTLY_TYPED_ARG(position), STRICTLY_TYPED_ARG(byteLength)) const
+ {
+ STRICT_ARG_TYPE(size_t);
+ return getAsBytesInternal(dest, position, byteLength);
}
// Creates an SkData and copies this SharedBuffer's contents to that
@@ -155,7 +168,7 @@ private:
void mergeSegmentsIntoBuffer() const;
void appendInternal(const char* data, size_t);
- bool getAsBytesInternal(void* dest, size_t) const;
+ bool getAsBytesInternal(void* dest, size_t, size_t) const;
size_t getSomeDataInternal(const char*& data, size_t position) const;
size_t m_size;
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/SharedBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698