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

Unified Diff: webkit/fileapi/file_system_usage_tracker.h

Issue 6426001: Add 1st cut of FileSystemUsageTracker that tracks the usage changes in FileSystem API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: webkit/fileapi/file_system_usage_tracker.h
diff --git a/webkit/fileapi/file_system_usage_tracker.h b/webkit/fileapi/file_system_usage_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..c6e4bfdcfab4264f452dfd8a286d894f20b200ca
--- /dev/null
+++ b/webkit/fileapi/file_system_usage_tracker.h
@@ -0,0 +1,67 @@
+// 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 {
+
+class FileSystemUsageTracker {
ericu 2011/02/09 02:05:22 What's the lifetime of this object? Is there guar
kinuko 2011/02/09 05:22:36 Added comments, as I interpreted your questions as
ericu 2011/02/09 23:03:37 Great--thanks.
+ 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;
+ friend class GetUsageTask;
michaeln 2011/02/09 00:25:36 since it's an inner class, do you need the 'friend
kinuko 2011/02/09 05:22:36 Well... I'm not sure if it works in all the compil
+
+ void RegisterUsageTask(GetUsageTask* task);
+ void UnregisterUsageTask(GetUsageTask* task);
ericu 2011/02/09 02:05:22 I'd probably call these [Un]RegisterGetUsageTask,
kinuko 2011/02/09 05:22:36 Agreed, except that the method names reflect the f
ericu 2011/02/09 23:03:37 OK.
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698