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

Unified Diff: include/core/SkFlattenableBuffers.h

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Adding validation helper file Created 7 years, 3 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
Index: include/core/SkFlattenableBuffers.h
diff --git a/include/core/SkFlattenableBuffers.h b/include/core/SkFlattenableBuffers.h
index 03c03f3877e6f8e3f508d29e371d5c7ebd91624e..f28df3512b81c2900a4436bff2ee376d79eeb105 100644
--- a/include/core/SkFlattenableBuffers.h
+++ b/include/core/SkFlattenableBuffers.h
@@ -41,14 +41,20 @@ public:
kCrossProcess_Flag = 1 << 0,
kScalarIsFloat_Flag = 1 << 1,
kPtrIs64Bit_Flag = 1 << 2,
+ /** The kValidation_Flag is used to force stream validations (by making
+ * sure that no operation reads past the end of the stream, for example)
+ * and error handling if any reading operation yields an invalid value.
+ */
+ kValidation_Flag = 1 << 3,
};
void setFlags(uint32_t flags) { fFlags = flags; }
uint32_t getFlags() const { return fFlags; }
- bool isCrossProcess() const { return SkToBool(fFlags & kCrossProcess_Flag); }
+ bool isCrossProcess() const { return SkToBool(fFlags & (kCrossProcess_Flag | kValidation_Flag)); }
bool isScalarFloat() const { return SkToBool(fFlags & kScalarIsFloat_Flag); }
bool isPtr64Bit() const { return SkToBool(fFlags & kPtrIs64Bit_Flag); }
+ bool isSecure() const { return SkToBool(fFlags & kValidation_Flag); }
reed1 2013/09/04 18:49:36 isValidating()?
sugoi1 2013/09/04 20:14:52 Done.
// primitives
virtual bool readBool() = 0;
@@ -102,6 +108,13 @@ public:
return static_cast<T*>(this->readFlattenable());
}
+ void validateData(bool isValid) {
+ fError |= !isValid;
+ }
+
+protected:
+ bool fError;
+
private:
uint32_t fFlags;
};
@@ -154,13 +167,22 @@ public:
enum Flags {
kCrossProcess_Flag = 0x01,
+ /** The kValidation_Flag is used here to make sure the write operation
+ * is symmetric with the read operation using the equivalent flag
+ * SkFlattenableReadBuffer::kValidation_Flag.
+ */
+ kValidation_Flag = 0x02,
};
uint32_t getFlags() const { return fFlags; }
void setFlags(uint32_t flags) { fFlags = flags; }
bool isCrossProcess() const {
- return SkToBool(fFlags & kCrossProcess_Flag);
+ return SkToBool(fFlags & (kCrossProcess_Flag | kValidation_Flag));
+ }
+
+ bool isSecure() const {
reed1 2013/09/04 18:49:36 isValidating()?
sugoi1 2013/09/04 20:14:52 Done.
+ return SkToBool(fFlags & kValidation_Flag);
}
bool persistTypeface() const { return (fFlags & kCrossProcess_Flag) != 0; }

Powered by Google App Engine
This is Rietveld 408576698