• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BLOB_INFO_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BLOB_INFO_H_
7 
8 #include <string>
9 
10 #include "base/callback.h"
11 #include "base/files/file_path.h"
12 #include "base/time/time.h"
13 #include "content/common/content_export.h"
14 #include "webkit/common/blob/shareable_file_reference.h"
15 
16 namespace content {
17 
18 class CONTENT_EXPORT IndexedDBBlobInfo {
19  public:
20   typedef webkit_blob::ShareableFileReference::FinalReleaseCallback
21       ReleaseCallback;
22   IndexedDBBlobInfo();
23   ~IndexedDBBlobInfo();
24   // These two are used for Blobs.
25   IndexedDBBlobInfo(const std::string& uuid,
26                     const base::string16& type,
27                     int64 size);
28   IndexedDBBlobInfo(const base::string16& type, int64 size, int64 key);
29   // These two are used for Files.
30   IndexedDBBlobInfo(const std::string& uuid,
31                     const base::FilePath& file_path,
32                     const base::string16& file_name,
33                     const base::string16& type);
34   IndexedDBBlobInfo(int64 key,
35                     const base::string16& type,
36                     const base::string16& file_name);
37 
is_file()38   bool is_file() const { return is_file_; }
uuid()39   const std::string& uuid() const { return uuid_; }
type()40   const base::string16& type() const { return type_; }
size()41   int64 size() const { return size_; }
file_name()42   const base::string16& file_name() const { return file_name_; }
key()43   int64 key() const { return key_; }
file_path()44   const base::FilePath& file_path() const { return file_path_; }
last_modified()45   const base::Time& last_modified() const { return last_modified_; }
mark_used_callback()46   const base::Closure& mark_used_callback() const {
47     return mark_used_callback_;
48   }
release_callback()49   const ReleaseCallback& release_callback() const { return release_callback_; }
50 
51   void set_size(int64 size);
52   void set_uuid(const std::string& uuid);
53   void set_file_path(const base::FilePath& file_path);
54   void set_last_modified(const base::Time& time);
55   void set_key(int64 key);
56   void set_mark_used_callback(const base::Closure& mark_used_callback);
57   void set_release_callback(const ReleaseCallback& release_callback);
58 
59  private:
60   bool is_file_;
61   std::string uuid_;          // Always for Blob; sometimes for File.
62   base::string16 type_;       // Mime type.
63   int64 size_;                // -1 if unknown for File.
64   base::string16 file_name_;  // Only for File.
65   base::FilePath file_path_;  // Only for File.
66   base::Time last_modified_;  // Only for File; valid only if size is.
67 
68   // Valid only when this comes out of the database.
69   int64 key_;
70   base::Closure mark_used_callback_;
71   ReleaseCallback release_callback_;
72 };
73 
74 }  // namespace content
75 
76 #endif  // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BLOB_INFO_H_
77