Add size_t bytesWritten() const to SkWStream.

BUG=skia:
R=reed@google.com, mtklein@google.com, robertphillips@google.com, bungeman@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/187653003

git-svn-id: http://skia.googlecode.com/svn/trunk@13684 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkDebug.cpp b/src/core/SkDebug.cpp
index d484f5e..b705a65 100644
--- a/src/core/SkDebug.cpp
+++ b/src/core/SkDebug.cpp
@@ -51,4 +51,9 @@
     return (unsigned)x;
 }
 
+size_t SkToSizeT(uintmax_t x) {
+    SkASSERT((size_t)x == x);
+    return (size_t)x;
+}
+
 #endif
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index 70f97d2..e766a1b 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -806,6 +806,7 @@
 {
 #if defined(SK_DEBUG) || defined(SK_DEVELOPER)
     SkDebugf("\n");
+    fBytesWritten++;
 #endif
 }
 
@@ -817,6 +818,7 @@
     s[size] = 0;
     SkDebugf("%s", s);
     delete[] s;
+    fBytesWritten += size+1;
 #endif
     return true;
 }
diff --git a/src/utils/SkMD5.h b/src/utils/SkMD5.h
index 0148641..4f50478 100644
--- a/src/utils/SkMD5.h
+++ b/src/utils/SkMD5.h
@@ -29,6 +29,8 @@
         return true;
     }
 
+    virtual size_t bytesWritten() const SK_OVERRIDE { return SkToSizeT(this->byteCount); }
+
     /** Processes input, adding it to the digest. Calling this after finish is undefined. */
     void update(const uint8_t* input, size_t length);
 
diff --git a/src/utils/SkSHA1.h b/src/utils/SkSHA1.h
index cf2cb8c..df8b9bf 100644
--- a/src/utils/SkSHA1.h
+++ b/src/utils/SkSHA1.h
@@ -29,6 +29,8 @@
         return true;
     }
 
+    virtual size_t bytesWritten() const SK_OVERRIDE { return SkToSizeT(this->byteCount); }
+
     /** Processes input, adding it to the digest. Calling this after finish is undefined. */
     void update(const uint8_t* input, size_t length);