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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/request_manager.h

Issue 194693002: [fsp] Add requestUnmount() method together with the request manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed some too strict thread checks. Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/callback.h"
12 #include "base/files/file.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/chromeos/file_system_provider/observer.h"
15 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h"
16
17 namespace base {
18 class DictionaryValue;
19 } // namespace base
20
21 namespace chromeos {
22 namespace file_system_provider {
23
24 typedef base::Callback<void(scoped_ptr<base::DictionaryValue>, bool has_next)>
25 SuccessCallback;
26 typedef base::Callback<void(base::File::Error)> ErrorCallback;
27
28 // Manages requests between the service, async utils and the providing
29 // extensions.
30 class RequestManager : public Observer {
31 public:
32 RequestManager();
33 virtual ~RequestManager();
34
35 // Creates a request and returns its request id (greater than 0). Returns 0 in
36 // case of an error (eg. too many requests). The passed callbacks can be NULL.
37 int CreateRequest(const ProvidedFileSystem& file_system,
38 const SuccessCallback& success_callback,
39 const ErrorCallback& error_callback);
40
41 // Handles successful response for the |request_id|. If |has_next| is false,
42 // then the request is disposed, after handling the |response|. On error,
43 // returns false, and the request is disposed.
44 bool FulfillRequest(const ProvidedFileSystem& file_system,
45 int request_id,
46 scoped_ptr<base::DictionaryValue> response,
47 bool has_next);
48
49 // Handles error response for the |request_id|. If handling the error fails,
50 // returns false. Always disposes the request.
51 bool RejectRequest(const ProvidedFileSystem& file_system,
52 int request_id,
53 base::File::Error error);
54
55 // file_system_provider::Observer overrides.
56 virtual void OnProvidedFileSystemMount(const ProvidedFileSystem& file_system,
57 base::File::Error error) OVERRIDE;
58 virtual void OnProvidedFileSystemUnmount(
59 const ProvidedFileSystem& file_system,
60 base::File::Error error) OVERRIDE;
61
62 private:
63 struct Request {
64 Request();
65 ~Request();
66
67 // Provided file system handling the request.
68 ProvidedFileSystem file_system;
69
70 // Callback to be called on success.
71 SuccessCallback success_callback;
72
73 // Callback to be called on error.
74 ErrorCallback error_callback;
75 };
76
77 typedef std::map<int, Request> RequestMap;
78
79 RequestMap requests_;
80 int next_id_;
81
82 DISALLOW_COPY_AND_ASSIGN(RequestManager);
83 };
84
85 } // namespace file_system_provider
86 } // namespace chromeos
87
88 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698