summaryrefslogtreecommitdiffstats
path: root/chrome/common/file_system/file_system_dispatcher.h
blob: 6fb9db5547ea850d0f69eba300951ffee47b486d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2010 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 CHROME_COMMON_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_H_
#define CHROME_COMMON_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_H_

#include <vector>

#include "base/basictypes.h"
#include "base/id_map.h"
#include "base/nullable_string16.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_message.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileError.h"

namespace WebKit {
struct WebFileInfo;
class WebFileSystemCallbacks;
struct WebFileSystemEntry;
}

namespace base {
struct PlatformFileInfo;
}

struct ViewMsg_FileSystem_DidReadDirectory_Params;

// Dispatches and sends file system related messages sent to/from a child
// process from/to the main browser process.  There is one instance
// per child process.  Messages are dispatched on the main child thread.
class FileSystemDispatcher {
 public:
  FileSystemDispatcher();
  ~FileSystemDispatcher();

  bool OnMessageReceived(const IPC::Message& msg);

  void Move(
      const string16& src_path,
      const string16& dest_path,
      WebKit::WebFileSystemCallbacks* callbacks);
  void Copy(
      const string16& src_path,
      const string16& dest_path,
      WebKit::WebFileSystemCallbacks* callbacks);
  void Remove(
      const string16& path,
      WebKit::WebFileSystemCallbacks* callbacks);
  void ReadMetadata(
      const string16& path,
      WebKit::WebFileSystemCallbacks* callbacks);
  void Create(
      const string16& path,
      bool exclusive,
      bool for_directory,
      WebKit::WebFileSystemCallbacks* callbacks);
  void Exists(
      const string16& path,
      bool for_directory,
      WebKit::WebFileSystemCallbacks* callbacks);
  void ReadDirectory(
      const string16& path,
      WebKit::WebFileSystemCallbacks* callbacks);

 private:
  void DidSucceed(int request_id);
  void DidReadMetadata(
      int request_id,
      const base::PlatformFileInfo& file_info);
  void DidReadDirectory(
      const ViewMsg_FileSystem_DidReadDirectory_Params& params);
  void DidFail(
      int request_id,
      WebKit::WebFileError);

  IDMap<WebKit::WebFileSystemCallbacks> callbacks_;

  DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcher);
};

#endif  // CHROME_COMMON_FILE_SYSTEM_FILE_SYSTEM_DISPATCHER_H_