diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-10 13:17:58 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-10 13:17:58 +0000 |
commit | 955dd7ebf6808dd93dd1aedc7390e7280e848f80 (patch) | |
tree | 6a9e559583084a956005c367249026647e3879bf /webkit/fileapi/file_system_usage_tracker.h | |
parent | 0c5e07b0a63a5aea8ab0c2b50177b4c99e7c9538 (diff) | |
download | chromium_src-955dd7ebf6808dd93dd1aedc7390e7280e848f80.zip chromium_src-955dd7ebf6808dd93dd1aedc7390e7280e848f80.tar.gz chromium_src-955dd7ebf6808dd93dd1aedc7390e7280e848f80.tar.bz2 |
Add 1st cut of FileSystemUsageTracker that tracks the usage changes in FileSystem API.
For now it has no meaningful implementation yet; mostly just for
defining a few interfaces.
BUG=
TEST=FileSystemUsageTrackerTest.DummyTest
Review URL: http://codereview.chromium.org/6426001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74429 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_usage_tracker.h')
-rw-r--r-- | webkit/fileapi/file_system_usage_tracker.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/webkit/fileapi/file_system_usage_tracker.h b/webkit/fileapi/file_system_usage_tracker.h new file mode 100644 index 0000000..10a5177 --- /dev/null +++ b/webkit/fileapi/file_system_usage_tracker.h @@ -0,0 +1,71 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_TRACKER_H_ +#define WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_TRACKER_H_ + +#include <deque> +#include <list> +#include <map> +#include <string> + +#include "base/basictypes.h" +#include "base/callback.h" +#include "base/file_path.h" +#include "base/ref_counted.h" +#include "webkit/fileapi/file_system_types.h" + +class GURL; + +namespace base { +class MessageLoopProxy; +} + +namespace fileapi { + +// Owned by the SandboxedFileSystemContext, which is a per-profile +// instance, and has the same lifetime as the SandboxedFileSystemContext. +// It's going to be created and destroyed on the IO thread in chrome. +// (The destruction on the same thread where it is created was guaranteed +// by its owner, SandboxedFileSystemContext.) +class FileSystemUsageTracker { + public: + FileSystemUsageTracker( + scoped_refptr<base::MessageLoopProxy> file_message_loop, + const FilePath& profile_path, + bool is_incognito); + ~FileSystemUsageTracker(); + + // Get the amount of data stored in the filesystem specified by + // |origin_url| and |type|. + typedef Callback1<int64 /* usage */>::Type GetUsageCallback; + void GetOriginUsage(const GURL& origin_url, + fileapi::FileSystemType type, + GetUsageCallback* callback); + + private: + class GetUsageTask; + + void RegisterUsageTask(GetUsageTask* task); + void UnregisterUsageTask(GetUsageTask* task); + + void DidGetOriginUsage(const std::string& fs_name, int64 usage); + + scoped_refptr<base::MessageLoopProxy> file_message_loop_; + FilePath base_path_; + bool is_incognito_; + + typedef std::deque<GetUsageTask*> UsageTaskQueue; + UsageTaskQueue running_usage_tasks_; + + typedef std::list<GetUsageCallback*> PendingCallbackList; + typedef std::map<std::string, PendingCallbackList> PendingUsageCallbackMap; + PendingUsageCallbackMap pending_usage_callbacks_; + + DISALLOW_COPY_AND_ASSIGN(FileSystemUsageTracker); +}; + +} // namespace fileapi + +#endif // WEBKIT_FILEAPI_FILE_SYSTEM_USAGE_TRACKER_H_ |