Home | History | Annotate | Download | only in fileapi
      1 // Copyright (c) 2012 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 WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_
      6 #define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_
      7 
      8 #include <set>
      9 #include <string>
     10 
     11 #include "base/basictypes.h"
     12 #include "base/platform_file.h"
     13 #include "url/gurl.h"
     14 #include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
     15 #include "webkit/browser/webkit_storage_browser_export.h"
     16 #include "webkit/common/fileapi/file_system_types.h"
     17 
     18 namespace base {
     19 class SequencedTaskRunner;
     20 }
     21 
     22 namespace quota {
     23 class QuotaManagerProxy;
     24 }
     25 
     26 namespace fileapi {
     27 
     28 class FileSystemContext;
     29 
     30 // An abstract interface that provides common quota-related utility functions
     31 // for file_system_quota_client.
     32 // All the methods of this class are synchronous and need to be called on
     33 // the thread that the method name implies.
     34 class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemQuotaUtil {
     35  public:
     36   virtual ~FileSystemQuotaUtil() {}
     37 
     38   // Deletes the data on the origin and reports the amount of deleted data
     39   // to the quota manager via |proxy|.
     40   virtual base::PlatformFileError DeleteOriginDataOnFileThread(
     41       FileSystemContext* context,
     42       quota::QuotaManagerProxy* proxy,
     43       const GURL& origin_url,
     44       FileSystemType type) = 0;
     45 
     46   virtual void GetOriginsForTypeOnFileThread(fileapi::FileSystemType type,
     47                                              std::set<GURL>* origins) = 0;
     48 
     49   virtual void GetOriginsForHostOnFileThread(fileapi::FileSystemType type,
     50                                              const std::string& host,
     51                                              std::set<GURL>* origins) = 0;
     52 
     53   // Returns the amount of data used for the origin for usage tracking.
     54   virtual int64 GetOriginUsageOnFileThread(
     55       fileapi::FileSystemContext* file_system_context,
     56       const GURL& origin_url,
     57       fileapi::FileSystemType type) = 0;
     58 
     59   virtual void InvalidateUsageCache(const GURL& origin_url,
     60                                     fileapi::FileSystemType type) = 0;
     61   virtual void StickyInvalidateUsageCache(const GURL& origin,
     62                                           fileapi::FileSystemType type) = 0;
     63 
     64   virtual void AddFileUpdateObserver(
     65       FileSystemType type,
     66       FileUpdateObserver* observer,
     67       base::SequencedTaskRunner* task_runner) = 0;
     68   virtual void AddFileChangeObserver(
     69       FileSystemType type,
     70       FileChangeObserver* observer,
     71       base::SequencedTaskRunner* task_runner) = 0;
     72   virtual void AddFileAccessObserver(
     73       FileSystemType type,
     74       FileAccessObserver* observer,
     75       base::SequencedTaskRunner* task_runner) = 0;
     76   virtual const UpdateObserverList* GetUpdateObservers(
     77       FileSystemType type) const = 0;
     78   virtual const ChangeObserverList* GetChangeObservers(
     79       FileSystemType type) const = 0;
     80   virtual const AccessObserverList* GetAccessObservers(
     81       FileSystemType type) const = 0;
     82 };
     83 
     84 }  // namespace fileapi
     85 
     86 #endif  // WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_
     87