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_MEDIA_GALLERIES_FILEAPI_ITUNES_FILE_UTIL_H_
6#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_FILE_UTIL_H_
7
8#include "base/memory/scoped_ptr.h"
9#include "base/memory/weak_ptr.h"
10#include "chrome/browser/media_galleries/fileapi/native_media_file_util.h"
11
12class ImportedMediaGalleryRegistry;
13
14namespace itunes {
15
16class ITunesDataProvider;
17
18extern const char kITunesLibraryXML[];
19extern const char kITunesMediaDir[];
20extern const char kITunesMusicDir[];
21extern const char kITunesAutoAddDir[];
22
23class ITunesFileUtil : public NativeMediaFileUtil {
24 public:
25  explicit ITunesFileUtil(MediaPathFilter* media_path_filter);
26  virtual ~ITunesFileUtil();
27
28 protected:
29  // NativeMediaFileUtil overrides.
30  virtual void GetFileInfoOnTaskRunnerThread(
31      scoped_ptr<storage::FileSystemOperationContext> context,
32      const storage::FileSystemURL& url,
33      const GetFileInfoCallback& callback) OVERRIDE;
34  virtual void ReadDirectoryOnTaskRunnerThread(
35      scoped_ptr<storage::FileSystemOperationContext> context,
36      const storage::FileSystemURL& url,
37      const ReadDirectoryCallback& callback) OVERRIDE;
38  virtual void CreateSnapshotFileOnTaskRunnerThread(
39      scoped_ptr<storage::FileSystemOperationContext> context,
40      const storage::FileSystemURL& url,
41      const CreateSnapshotFileCallback& callback) OVERRIDE;
42  virtual base::File::Error GetFileInfoSync(
43      storage::FileSystemOperationContext* context,
44      const storage::FileSystemURL& url,
45      base::File::Info* file_info,
46      base::FilePath* platform_path) OVERRIDE;
47  virtual base::File::Error ReadDirectorySync(
48      storage::FileSystemOperationContext* context,
49      const storage::FileSystemURL& url,
50      EntryList* file_list) OVERRIDE;
51  virtual base::File::Error DeleteDirectorySync(
52      storage::FileSystemOperationContext* context,
53      const storage::FileSystemURL& url) OVERRIDE;
54  virtual base::File::Error DeleteFileSync(
55      storage::FileSystemOperationContext* context,
56      const storage::FileSystemURL& url) OVERRIDE;
57  virtual base::File::Error CreateSnapshotFileSync(
58      storage::FileSystemOperationContext* context,
59      const storage::FileSystemURL& url,
60      base::File::Info* file_info,
61      base::FilePath* platform_path,
62      scoped_refptr<storage::ShareableFileReference>* file_ref) OVERRIDE;
63  virtual base::File::Error GetLocalFilePath(
64      storage::FileSystemOperationContext* context,
65      const storage::FileSystemURL& url,
66      base::FilePath* local_file_path) OVERRIDE;
67
68 private:
69  void GetFileInfoWithFreshDataProvider(
70      scoped_ptr<storage::FileSystemOperationContext> context,
71      const storage::FileSystemURL& url,
72      const GetFileInfoCallback& callback,
73      bool valid_parse);
74  void ReadDirectoryWithFreshDataProvider(
75      scoped_ptr<storage::FileSystemOperationContext> context,
76      const storage::FileSystemURL& url,
77      const ReadDirectoryCallback& callback,
78      bool valid_parse);
79  virtual void CreateSnapshotFileWithFreshDataProvider(
80      scoped_ptr<storage::FileSystemOperationContext> context,
81      const storage::FileSystemURL& url,
82      const CreateSnapshotFileCallback& callback,
83      bool valid_parse);
84
85  virtual ITunesDataProvider* GetDataProvider();
86
87  ImportedMediaGalleryRegistry* imported_registry_;
88
89  base::WeakPtrFactory<ITunesFileUtil> weak_factory_;
90
91  DISALLOW_COPY_AND_ASSIGN(ITunesFileUtil);
92};
93
94}  // namespace itunes
95
96#endif  // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_FILE_UTIL_H_
97