OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/common/extensions/api/file_system_provider.h" | 10 #include "chrome/common/extensions/api/file_system_provider.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 : Operation(event_router, file_system_info), | 76 : Operation(event_router, file_system_info), |
77 entry_path_(entry_path), | 77 entry_path_(entry_path), |
78 fields_(fields), | 78 fields_(fields), |
79 callback_(callback) { | 79 callback_(callback) { |
80 } | 80 } |
81 | 81 |
82 GetMetadata::~GetMetadata() { | 82 GetMetadata::~GetMetadata() { |
83 } | 83 } |
84 | 84 |
85 bool GetMetadata::Execute(int request_id) { | 85 bool GetMetadata::Execute(int request_id) { |
86 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue); | 86 using extensions::api::file_system_provider::GetMetadataRequestedOptions; |
87 values->SetString("entryPath", entry_path_.AsUTF8Unsafe()); | 87 |
88 values->SetBoolean( | 88 GetMetadataRequestedOptions options; |
89 "thumbnail", | 89 options.file_system_id = file_system_info_.file_system_id(); |
90 (fields_ & ProvidedFileSystemInterface::METADATA_FIELD_THUMBNAIL) != 0); | 90 options.request_id = request_id; |
| 91 options.entry_path = entry_path_.AsUTF8Unsafe(); |
| 92 options.thumbnail = |
| 93 fields_ & ProvidedFileSystemInterface::METADATA_FIELD_THUMBNAIL; |
91 | 94 |
92 return SendEvent( | 95 return SendEvent( |
93 request_id, | 96 request_id, |
94 extensions::api::file_system_provider::OnGetMetadataRequested::kEventName, | 97 extensions::api::file_system_provider::OnGetMetadataRequested::kEventName, |
95 values.Pass()); | 98 extensions::api::file_system_provider::OnGetMetadataRequested::Create( |
| 99 options)); |
96 } | 100 } |
97 | 101 |
98 void GetMetadata::OnSuccess(int /* request_id */, | 102 void GetMetadata::OnSuccess(int /* request_id */, |
99 scoped_ptr<RequestValue> result, | 103 scoped_ptr<RequestValue> result, |
100 bool has_more) { | 104 bool has_more) { |
101 scoped_ptr<EntryMetadata> metadata(new EntryMetadata); | 105 scoped_ptr<EntryMetadata> metadata(new EntryMetadata); |
102 const bool convert_result = | 106 const bool convert_result = |
103 ConvertRequestValueToFileInfo(result.Pass(), metadata.get()); | 107 ConvertRequestValueToFileInfo(result.Pass(), metadata.get()); |
104 | 108 |
105 if (!convert_result) { | 109 if (!convert_result) { |
106 LOG(ERROR) << "Failed to parse a response for the get metadata operation."; | 110 LOG(ERROR) << "Failed to parse a response for the get metadata operation."; |
107 callback_.Run(make_scoped_ptr<EntryMetadata>(NULL), | 111 callback_.Run(make_scoped_ptr<EntryMetadata>(NULL), |
108 base::File::FILE_ERROR_IO); | 112 base::File::FILE_ERROR_IO); |
109 return; | 113 return; |
110 } | 114 } |
111 | 115 |
112 callback_.Run(metadata.Pass(), base::File::FILE_OK); | 116 callback_.Run(metadata.Pass(), base::File::FILE_OK); |
113 } | 117 } |
114 | 118 |
115 void GetMetadata::OnError(int /* request_id */, | 119 void GetMetadata::OnError(int /* request_id */, |
116 scoped_ptr<RequestValue> /* result */, | 120 scoped_ptr<RequestValue> /* result */, |
117 base::File::Error error) { | 121 base::File::Error error) { |
118 callback_.Run(make_scoped_ptr<EntryMetadata>(NULL), error); | 122 callback_.Run(make_scoped_ptr<EntryMetadata>(NULL), error); |
119 } | 123 } |
120 } // namespace operations | 124 } // namespace operations |
121 } // namespace file_system_provider | 125 } // namespace file_system_provider |
122 } // namespace chromeos | 126 } // namespace chromeos |
OLD | NEW |