| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_FILEAPI_SANDBOX_QUOTA_OBSERVER_H_ | 5 #ifndef WEBKIT_FILEAPI_SANDBOX_QUOTA_OBSERVER_H_ |
| 6 #define WEBKIT_FILEAPI_SANDBOX_QUOTA_OBSERVER_H_ | 6 #define WEBKIT_FILEAPI_SANDBOX_QUOTA_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <map> |
| 9 |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 13 #include "webkit/fileapi/file_observers.h" | 15 #include "webkit/fileapi/file_observers.h" |
| 16 #include "webkit/fileapi/file_system_url.h" |
| 14 | 17 |
| 15 namespace base { | 18 namespace base { |
| 16 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
| 17 } | 20 } |
| 18 | 21 |
| 19 namespace quota { | 22 namespace quota { |
| 20 class QuotaManagerProxy; | 23 class QuotaManagerProxy; |
| 21 } | 24 } |
| 22 | 25 |
| 23 namespace fileapi { | 26 namespace fileapi { |
| 24 | 27 |
| 25 class FileSystemURL; | 28 class FileSystemURL; |
| 26 class ObfuscatedFileUtil; | 29 class ObfuscatedFileUtil; |
| 27 | 30 |
| 28 class SandboxQuotaObserver | 31 class SandboxQuotaObserver |
| 29 : public FileUpdateObserver, | 32 : public FileUpdateObserver, |
| 30 public FileAccessObserver { | 33 public FileAccessObserver { |
| 31 public: | 34 public: |
| 35 typedef std::map<FilePath, int64> PendingUpdateNotificationMap; |
| 36 |
| 32 SandboxQuotaObserver( | 37 SandboxQuotaObserver( |
| 33 quota::QuotaManagerProxy* quota_manager_proxy, | 38 quota::QuotaManagerProxy* quota_manager_proxy, |
| 34 base::SequencedTaskRunner* update_notify_runner, | 39 base::SequencedTaskRunner* update_notify_runner, |
| 35 ObfuscatedFileUtil* sandbox_file_util); | 40 ObfuscatedFileUtil* sandbox_file_util); |
| 36 virtual ~SandboxQuotaObserver(); | 41 virtual ~SandboxQuotaObserver(); |
| 37 | 42 |
| 38 // FileUpdateObserver overrides. | 43 // FileUpdateObserver overrides. |
| 39 virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE; | 44 virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE; |
| 40 virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE; | 45 virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE; |
| 41 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE; | 46 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE; |
| 42 | 47 |
| 43 // FileAccessObserver overrides. | 48 // FileAccessObserver overrides. |
| 44 virtual void OnAccess(const FileSystemURL& url) OVERRIDE; | 49 virtual void OnAccess(const FileSystemURL& url) OVERRIDE; |
| 45 | 50 |
| 46 private: | 51 private: |
| 52 void ApplyPendingUsageUpdate(); |
| 53 void UpdateUsageCacheFile(const FilePath& usage_file_path, int64 delta); |
| 54 |
| 47 FilePath GetUsageCachePath(const FileSystemURL& url); | 55 FilePath GetUsageCachePath(const FileSystemURL& url); |
| 48 | 56 |
| 49 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 57 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; |
| 50 scoped_refptr<base::SequencedTaskRunner> update_notify_runner_; | 58 scoped_refptr<base::SequencedTaskRunner> update_notify_runner_; |
| 51 | 59 |
| 52 // Not owned; sandbox_file_util_ should have identical lifetime with this. | 60 // Not owned; sandbox_file_util_ should have identical lifetime with this. |
| 53 ObfuscatedFileUtil* sandbox_file_util_; | 61 ObfuscatedFileUtil* sandbox_file_util_; |
| 54 | 62 |
| 63 PendingUpdateNotificationMap pending_update_notification_; |
| 64 bool running_delayed_cache_update_; |
| 65 |
| 55 DISALLOW_COPY_AND_ASSIGN(SandboxQuotaObserver); | 66 DISALLOW_COPY_AND_ASSIGN(SandboxQuotaObserver); |
| 56 }; | 67 }; |
| 57 | 68 |
| 58 } // namespace fileapi | 69 } // namespace fileapi |
| 59 | 70 |
| 60 #endif // WEBKIT_FILEAPI_SANDBOX_QUOTA_OBSERVER_H_ | 71 #endif // WEBKIT_FILEAPI_SANDBOX_QUOTA_OBSERVER_H_ |
| OLD | NEW |