Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / drive / debug_info_collector.h
1 // Copyright 2013 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 CHROME_BROWSER_CHROMEOS_DRIVE_DEBUG_INFO_COLLECTOR_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DEBUG_INFO_COLLECTOR_H_
7
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "chrome/browser/chromeos/drive/file_system_interface.h"
11
12 namespace drive {
13
14 // This class provides some methods which are useful to show the debug
15 // info on chrome://drive-internals page.
16 // All the method should be called on UI thread.
17 class DebugInfoCollector {
18  public:
19   // Callback for ReadDirectory().
20   typedef base::Callback<void(FileError error,
21                               scoped_ptr<ResourceEntryVector> entries)>
22       ReadDirectoryCallback;
23
24   // Callback for IterateFileCache().
25   typedef base::Callback<void(const std::string& id,
26                               const FileCacheEntry& cache_entry)>
27       IterateFileCacheCallback;
28
29   DebugInfoCollector(internal::ResourceMetadata* metadata,
30                      FileSystemInterface* file_system,
31                      base::SequencedTaskRunner* blocking_task_runner);
32   ~DebugInfoCollector();
33
34   // Finds a locally stored entry (a file or a directory) by |file_path|.
35   // |callback| must not be null.
36   void GetResourceEntry(const base::FilePath& file_path,
37                         const GetResourceEntryCallback& callback);
38
39   // Finds and reads a directory by |file_path|.
40   // |callback| must not be null.
41   void ReadDirectory(const base::FilePath& file_path,
42                      const ReadDirectoryCallback& callback);
43
44
45   // Iterates all files in the file cache and calls |iteration_callback| for
46   // each file. |completion_callback| is run upon completion.
47   // |iteration_callback| and |completion_callback| must not be null.
48   void IterateFileCache(const IterateFileCacheCallback& iteration_callback,
49                         const base::Closure& completion_callback);
50
51   // Returns miscellaneous metadata of the file system like the largest
52   // timestamp. |callback| must not be null.
53   void GetMetadata(const GetFilesystemMetadataCallback& callback);
54
55  private:
56   internal::ResourceMetadata* metadata_;  // No owned.
57   FileSystemInterface* file_system_;  // Not owned.
58   scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
59
60   DISALLOW_COPY_AND_ASSIGN(DebugInfoCollector);
61 };
62
63 }  // namespace drive
64
65 #endif  // CHROME_BROWSER_CHROMEOS_DRIVE_DEBUG_INFO_COLLECTOR_H_