Fix SkFILEStream.

Change-Id: I8c66e4e3e857227aed3d0bc497982f4c0d96d917
Reviewed-on: https://skia-review.googlesource.com/9498
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 419ef7b..10929a8 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -12,6 +12,8 @@
 #include "SkRefCnt.h"
 #include "SkScalar.h"
 
+#include <memory.h>
+
 class SkStream;
 class SkStreamRewindable;
 class SkStreamSeekable;
@@ -232,7 +234,6 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////
 
-#include "SkString.h"
 #include <stdio.h>
 
 /** A stream that wraps a C FILE* file stream. */
@@ -241,28 +242,20 @@
     /** Initialize the stream by calling sk_fopen on the specified path.
      *  This internal stream will be closed in the destructor.
      */
-    explicit SkFILEStream(const char path[] = NULL);
+    explicit SkFILEStream(const char path[] = nullptr);
 
-    enum Ownership {
-        kCallerPasses_Ownership,
-        kCallerRetains_Ownership
-    };
     /** Initialize the stream with an existing C file stream.
-     *  While this stream exists, it assumes exclusive access to the C file stream.
-     *  The C file stream will be closed in the destructor unless the caller specifies
-     *  kCallerRetains_Ownership.
+     *  The C file stream will be closed in the destructor.
      */
-    explicit SkFILEStream(FILE* file, Ownership ownership = kCallerPasses_Ownership);
+    explicit SkFILEStream(FILE* file);
 
     virtual ~SkFILEStream();
 
     /** Returns true if the current path could be opened. */
-    bool isValid() const { return fFILE != NULL; }
+    bool isValid() const { return fFILE != nullptr; }
 
-    /** Close the current file, and open a new file with the specified path.
-     *  If path is NULL, just close the current file.
-     */
-    void setPath(const char path[]);
+    /** Close this SkFILEStream. */
+    void close();
 
     size_t read(void* buffer, size_t size) override;
     bool isAtEnd() const override;
@@ -280,11 +273,14 @@
     const void* getMemoryBase() override;
 
 private:
-    FILE*       fFILE;
-    SkString    fName;
-    Ownership   fOwnership;
-    // fData is lazilly initialized when needed.
-    mutable sk_sp<SkData> fData;
+    explicit SkFILEStream(std::shared_ptr<FILE>, size_t size, size_t offset);
+    explicit SkFILEStream(std::shared_ptr<FILE>, size_t size, size_t offset, size_t originalOffset);
+
+    std::shared_ptr<FILE> fFILE;
+    // My own council will I keep on sizes and offsets.
+    size_t fSize;
+    size_t fOffset;
+    size_t fOriginalOffset;
 
     typedef SkStreamAsset INHERITED;
 };