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

Side by Side Diff: webkit/browser/blob/blob_data_handle.h

Issue 259773006: Allow BlobDataHandles to be copied, and have their UUIDs read, on any thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Experimental Windows build fix Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_BROWSER_BLOB_BLOB_DATA_HANDLE_H_ 5 #ifndef WEBKIT_BROWSER_BLOB_BLOB_DATA_HANDLE_H_
6 #define WEBKIT_BROWSER_BLOB_BLOB_DATA_HANDLE_H_ 6 #define WEBKIT_BROWSER_BLOB_BLOB_DATA_HANDLE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 10 matching lines...) Expand all
21 class BlobData; 21 class BlobData;
22 class BlobStorageContext; 22 class BlobStorageContext;
23 23
24 // A scoper object for use in chrome's main browser process, ensures 24 // A scoper object for use in chrome's main browser process, ensures
25 // the underlying BlobData and its uuid remain in BlobStorageContext's 25 // the underlying BlobData and its uuid remain in BlobStorageContext's
26 // collection for the duration. This object has delete semantics and 26 // collection for the duration. This object has delete semantics and
27 // maybe deleted on any thread. 27 // maybe deleted on any thread.
28 class WEBKIT_STORAGE_BROWSER_EXPORT BlobDataHandle 28 class WEBKIT_STORAGE_BROWSER_EXPORT BlobDataHandle
29 : public base::SupportsUserData::Data { 29 : public base::SupportsUserData::Data {
30 public: 30 public:
31 BlobDataHandle(const BlobDataHandle& other); // May be copied on any thread.
31 virtual ~BlobDataHandle(); // Maybe be deleted on any thread. 32 virtual ~BlobDataHandle(); // Maybe be deleted on any thread.
32 BlobData* data() const; // May only be accessed on the IO thread. 33 BlobData* data() const; // May only be accessed on the IO thread.
33 34
35 std::string uuid() const; // May be accessed on any thread.
36
34 private: 37 private:
38 class BlobDataHandleShared
michaeln 2014/04/28 18:25:22 too bad this has to be in the .h file :(
39 : public base::RefCountedThreadSafe<BlobDataHandleShared> {
40 public:
41 BlobDataHandleShared(BlobData* blob_data,
42 BlobStorageContext* context,
43 base::SequencedTaskRunner* task_runner);
44
45 BlobData* data() const;
46 const std::string& uuid() const;
47
48 private:
49 friend class base::DeleteHelper<BlobDataHandleShared>;
50 friend class base::RefCountedThreadSafe<BlobDataHandleShared>;
51 friend class BlobDataHandle;
52
53 virtual ~BlobDataHandleShared();
54
55 scoped_refptr<BlobData> blob_data_;
56 base::WeakPtr<BlobStorageContext> context_;
57 scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
58
59 DISALLOW_COPY_AND_ASSIGN(BlobDataHandleShared);
60 };
61
35 friend class BlobStorageContext; 62 friend class BlobStorageContext;
36 BlobDataHandle(BlobData* blob_data, BlobStorageContext* context, 63 BlobDataHandle(BlobData* blob_data, BlobStorageContext* context,
37 base::SequencedTaskRunner* task_runner); 64 base::SequencedTaskRunner* task_runner);
38 65
39 static void DeleteHelper(
40 base::WeakPtr<BlobStorageContext> context,
41 BlobData* blob_data);
42
43 BlobData* blob_data_; // Intentionally a raw ptr to a non-thread-safe ref.
44 base::WeakPtr<BlobStorageContext> context_;
45 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; 66 scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
46 67 scoped_refptr<BlobDataHandleShared> shared_;
47 DISALLOW_COPY_AND_ASSIGN(BlobDataHandle);
48 }; 68 };
49 69
50 } // namespace webkit_blob 70 } // namespace webkit_blob
51 71
52 #endif // WEBKIT_BROWSER_BLOB_BLOB_DATA_HANDLE_H_ 72 #endif // WEBKIT_BROWSER_BLOB_BLOB_DATA_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698