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

Side by Side Diff: third_party/WebKit/Source/platform/exported/WebFileSystemCallbacks.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #include "public/platform/WebFileSystemCallbacks.h" 31 #include "public/platform/WebFileSystemCallbacks.h"
32 32
33 #include "platform/AsyncFileSystemCallbacks.h" 33 #include "platform/AsyncFileSystemCallbacks.h"
34 #include "platform/FileMetadata.h" 34 #include "platform/FileMetadata.h"
35 #include "public/platform/WebFileInfo.h" 35 #include "public/platform/WebFileInfo.h"
36 #include "public/platform/WebFileSystem.h" 36 #include "public/platform/WebFileSystem.h"
37 #include "public/platform/WebFileSystemEntry.h" 37 #include "public/platform/WebFileSystemEntry.h"
38 #include "public/platform/WebFileWriter.h" 38 #include "public/platform/WebFileWriter.h"
39 #include "public/platform/WebString.h" 39 #include "public/platform/WebString.h"
40 #include "wtf/PassOwnPtr.h"
40 #include "wtf/PassRefPtr.h" 41 #include "wtf/PassRefPtr.h"
41 #include "wtf/PtrUtil.h"
42 #include "wtf/RefCounted.h" 42 #include "wtf/RefCounted.h"
43 #include <memory>
44 43
45 namespace blink { 44 namespace blink {
46 45
47 class WebFileSystemCallbacksPrivate : public RefCounted<WebFileSystemCallbacksPr ivate> { 46 class WebFileSystemCallbacksPrivate : public RefCounted<WebFileSystemCallbacksPr ivate> {
48 public: 47 public:
49 static PassRefPtr<WebFileSystemCallbacksPrivate> create(std::unique_ptr<Asyn cFileSystemCallbacks> callbacks) 48 static PassRefPtr<WebFileSystemCallbacksPrivate> create(PassOwnPtr<AsyncFile SystemCallbacks> callbacks)
50 { 49 {
51 return adoptRef(new WebFileSystemCallbacksPrivate(std::move(callbacks))) ; 50 return adoptRef(new WebFileSystemCallbacksPrivate(std::move(callbacks))) ;
52 } 51 }
53 52
54 AsyncFileSystemCallbacks* callbacks() { return m_callbacks.get(); } 53 AsyncFileSystemCallbacks* callbacks() { return m_callbacks.get(); }
55 54
56 private: 55 private:
57 WebFileSystemCallbacksPrivate(std::unique_ptr<AsyncFileSystemCallbacks> call backs) : m_callbacks(std::move(callbacks)) { } 56 WebFileSystemCallbacksPrivate(PassOwnPtr<AsyncFileSystemCallbacks> callbacks ) : m_callbacks(std::move(callbacks)) { }
58 std::unique_ptr<AsyncFileSystemCallbacks> m_callbacks; 57 OwnPtr<AsyncFileSystemCallbacks> m_callbacks;
59 }; 58 };
60 59
61 WebFileSystemCallbacks::WebFileSystemCallbacks(std::unique_ptr<AsyncFileSystemCa llbacks>&& callbacks) 60 WebFileSystemCallbacks::WebFileSystemCallbacks(PassOwnPtr<AsyncFileSystemCallbac ks>&& callbacks)
62 { 61 {
63 m_private = WebFileSystemCallbacksPrivate::create(std::move(callbacks)); 62 m_private = WebFileSystemCallbacksPrivate::create(std::move(callbacks));
64 } 63 }
65 64
66 void WebFileSystemCallbacks::reset() 65 void WebFileSystemCallbacks::reset()
67 { 66 {
68 m_private.reset(); 67 m_private.reset();
69 } 68 }
70 69
71 void WebFileSystemCallbacks::assign(const WebFileSystemCallbacks& other) 70 void WebFileSystemCallbacks::assign(const WebFileSystemCallbacks& other)
(...skipping 18 matching lines...) Expand all
90 fileMetadata.platformPath = webFileInfo.platformPath; 89 fileMetadata.platformPath = webFileInfo.platformPath;
91 m_private->callbacks()->didReadMetadata(fileMetadata); 90 m_private->callbacks()->didReadMetadata(fileMetadata);
92 m_private.reset(); 91 m_private.reset();
93 } 92 }
94 93
95 void WebFileSystemCallbacks::didCreateSnapshotFile(const WebFileInfo& webFileInf o) 94 void WebFileSystemCallbacks::didCreateSnapshotFile(const WebFileInfo& webFileInf o)
96 { 95 {
97 ASSERT(!m_private.isNull()); 96 ASSERT(!m_private.isNull());
98 // It's important to create a BlobDataHandle that refers to the platform fil e path prior 97 // It's important to create a BlobDataHandle that refers to the platform fil e path prior
99 // to return from this method so the underlying file will not be deleted. 98 // to return from this method so the underlying file will not be deleted.
100 std::unique_ptr<BlobData> blobData = BlobData::create(); 99 OwnPtr<BlobData> blobData = BlobData::create();
101 blobData->appendFile(webFileInfo.platformPath, 0, webFileInfo.length, invali dFileTime()); 100 blobData->appendFile(webFileInfo.platformPath, 0, webFileInfo.length, invali dFileTime());
102 RefPtr<BlobDataHandle> snapshotBlob = BlobDataHandle::create(std::move(blobD ata), webFileInfo.length); 101 RefPtr<BlobDataHandle> snapshotBlob = BlobDataHandle::create(std::move(blobD ata), webFileInfo.length);
103 102
104 FileMetadata fileMetadata; 103 FileMetadata fileMetadata;
105 fileMetadata.modificationTime = webFileInfo.modificationTime; 104 fileMetadata.modificationTime = webFileInfo.modificationTime;
106 fileMetadata.length = webFileInfo.length; 105 fileMetadata.length = webFileInfo.length;
107 fileMetadata.type = static_cast<FileMetadata::Type>(webFileInfo.type); 106 fileMetadata.type = static_cast<FileMetadata::Type>(webFileInfo.type);
108 fileMetadata.platformPath = webFileInfo.platformPath; 107 fileMetadata.platformPath = webFileInfo.platformPath;
109 m_private->callbacks()->didCreateSnapshotFile(fileMetadata, snapshotBlob); 108 m_private->callbacks()->didCreateSnapshotFile(fileMetadata, snapshotBlob);
110 m_private.reset(); 109 m_private.reset();
(...skipping 18 matching lines...) Expand all
129 void WebFileSystemCallbacks::didResolveURL(const WebString& name, const WebURL& rootURL, WebFileSystemType type, const WebString& filePath, bool isDirectory) 128 void WebFileSystemCallbacks::didResolveURL(const WebString& name, const WebURL& rootURL, WebFileSystemType type, const WebString& filePath, bool isDirectory)
130 { 129 {
131 ASSERT(!m_private.isNull()); 130 ASSERT(!m_private.isNull());
132 m_private->callbacks()->didResolveURL(name, rootURL, static_cast<FileSystemT ype>(type), filePath, isDirectory); 131 m_private->callbacks()->didResolveURL(name, rootURL, static_cast<FileSystemT ype>(type), filePath, isDirectory);
133 m_private.reset(); 132 m_private.reset();
134 } 133 }
135 134
136 void WebFileSystemCallbacks::didCreateFileWriter(WebFileWriter* webFileWriter, l ong long length) 135 void WebFileSystemCallbacks::didCreateFileWriter(WebFileWriter* webFileWriter, l ong long length)
137 { 136 {
138 ASSERT(!m_private.isNull()); 137 ASSERT(!m_private.isNull());
139 m_private->callbacks()->didCreateFileWriter(wrapUnique(webFileWriter), lengt h); 138 m_private->callbacks()->didCreateFileWriter(adoptPtr(webFileWriter), length) ;
140 m_private.reset(); 139 m_private.reset();
141 } 140 }
142 141
143 void WebFileSystemCallbacks::didFail(WebFileError error) 142 void WebFileSystemCallbacks::didFail(WebFileError error)
144 { 143 {
145 ASSERT(!m_private.isNull()); 144 ASSERT(!m_private.isNull());
146 m_private->callbacks()->didFail(error); 145 m_private->callbacks()->didFail(error);
147 m_private.reset(); 146 m_private.reset();
148 } 147 }
149 148
150 bool WebFileSystemCallbacks::shouldBlockUntilCompletion() const 149 bool WebFileSystemCallbacks::shouldBlockUntilCompletion() const
151 { 150 {
152 ASSERT(!m_private.isNull()); 151 ASSERT(!m_private.isNull());
153 return m_private->callbacks()->shouldBlockUntilCompletion(); 152 return m_private->callbacks()->shouldBlockUntilCompletion();
154 } 153 }
155 154
156 } // namespace blink 155 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698