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.
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DEBUG_INFO_COLLECTOR_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DEBUG_INFO_COLLECTOR_H_
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "base/threading/thread_checker.h"
11 #include "components/drive/file_system_interface.h"
15 // This class provides some methods which are useful to show the debug
16 // info on chrome://drive-internals page.
17 // All the method should be called on UI thread.
18 class DebugInfoCollector
{
20 // Callback for ReadDirectory().
21 typedef base::Callback
<void(FileError error
,
22 scoped_ptr
<ResourceEntryVector
> entries
)>
23 ReadDirectoryCallback
;
25 // Callback for IterateFileCache().
26 typedef base::Callback
<void(const std::string
& id
,
27 const FileCacheEntry
& cache_entry
)>
28 IterateFileCacheCallback
;
30 DebugInfoCollector(internal::ResourceMetadata
* metadata
,
31 FileSystemInterface
* file_system
,
32 base::SequencedTaskRunner
* blocking_task_runner
);
33 ~DebugInfoCollector();
35 // Finds a locally stored entry (a file or a directory) by |file_path|.
36 // |callback| must not be null.
37 void GetResourceEntry(const base::FilePath
& file_path
,
38 const GetResourceEntryCallback
& callback
);
40 // Finds and reads a directory by |file_path|.
41 // |callback| must not be null.
42 void ReadDirectory(const base::FilePath
& file_path
,
43 const ReadDirectoryCallback
& callback
);
46 // Iterates all files in the file cache and calls |iteration_callback| for
47 // each file. |completion_callback| is run upon completion.
48 // |iteration_callback| and |completion_callback| must not be null.
49 void IterateFileCache(const IterateFileCacheCallback
& iteration_callback
,
50 const base::Closure
& completion_callback
);
52 // Returns miscellaneous metadata of the file system like the largest
53 // timestamp. |callback| must not be null.
54 void GetMetadata(const GetFilesystemMetadataCallback
& callback
);
57 internal::ResourceMetadata
* metadata_
; // No owned.
58 FileSystemInterface
* file_system_
; // Not owned.
59 scoped_refptr
<base::SequencedTaskRunner
> blocking_task_runner_
;
61 base::ThreadChecker thread_checker_
;
63 DISALLOW_COPY_AND_ASSIGN(DebugInfoCollector
);
68 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DEBUG_INFO_COLLECTOR_H_