• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_VALUE_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_VALUE_H_
7 
8 #include <string>
9 
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/common/extensions/api/file_system_provider_internal.h"
12 
13 namespace chromeos {
14 namespace file_system_provider {
15 
16 // Holds a parsed value returned by a providing extension. Each accessor can
17 // return NULL in case the requested value type is not available. It is used
18 // to pass values of success callbacks.
19 class RequestValue {
20  public:
21   // Creates an empty value. Use static methods to create a value holding a
22   // proper content.
23   RequestValue();
24 
25   virtual ~RequestValue();
26 
27   static scoped_ptr<RequestValue> CreateForUnmountSuccess(
28       scoped_ptr<extensions::api::file_system_provider_internal::
29                      UnmountRequestedSuccess::Params> params);
30 
31   static scoped_ptr<RequestValue> CreateForGetMetadataSuccess(
32       scoped_ptr<extensions::api::file_system_provider_internal::
33                      GetMetadataRequestedSuccess::Params> params);
34 
35   static scoped_ptr<RequestValue> CreateForReadDirectorySuccess(
36       scoped_ptr<extensions::api::file_system_provider_internal::
37                      ReadDirectoryRequestedSuccess::Params> params);
38 
39   static scoped_ptr<RequestValue> CreateForReadFileSuccess(
40       scoped_ptr<extensions::api::file_system_provider_internal::
41                      ReadFileRequestedSuccess::Params> params);
42 
43   static scoped_ptr<RequestValue> CreateForTesting(const std::string& params);
44 
45   const extensions::api::file_system_provider_internal::
46       UnmountRequestedSuccess::Params*
unmount_success_params()47       unmount_success_params() const {
48     return unmount_success_params_.get();
49   }
50 
51   const extensions::api::file_system_provider_internal::
52       GetMetadataRequestedSuccess::Params*
get_metadata_success_params()53       get_metadata_success_params() const {
54     return get_metadata_success_params_.get();
55   }
56 
57   const extensions::api::file_system_provider_internal::
58       ReadDirectoryRequestedSuccess::Params*
read_directory_success_params()59       read_directory_success_params() const {
60     return read_directory_success_params_.get();
61   }
62 
63   const extensions::api::file_system_provider_internal::
64       ReadFileRequestedSuccess::Params*
read_file_success_params()65       read_file_success_params() const {
66     return read_file_success_params_.get();
67   }
68 
testing_params()69   const std::string* testing_params() const { return testing_params_.get(); }
70 
71  private:
72   scoped_ptr<extensions::api::file_system_provider_internal::
73                  UnmountRequestedSuccess::Params> unmount_success_params_;
74   scoped_ptr<extensions::api::file_system_provider_internal::
75                  GetMetadataRequestedSuccess::Params>
76       get_metadata_success_params_;
77   scoped_ptr<extensions::api::file_system_provider_internal::
78                  ReadDirectoryRequestedSuccess::Params>
79       read_directory_success_params_;
80   scoped_ptr<extensions::api::file_system_provider_internal::
81                  ReadFileRequestedSuccess::Params> read_file_success_params_;
82   scoped_ptr<std::string> testing_params_;
83 
84   DISALLOW_COPY_AND_ASSIGN(RequestValue);
85 };
86 
87 }  // namespace file_system_provider
88 }  // namespace chromeos
89 
90 #endif  // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_REQUEST_VALUE_H_
91