1cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// found in the LICENSE file. 4cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 5cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPEN_FILE_H_ 6cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPEN_FILE_H_ 7cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 8cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "base/files/file.h" 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/file_system_provider/operations/operation.h" 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h" 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h" 13cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/file_system_provider/request_value.h" 141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "storage/browser/fileapi/async_file_util.h" 15cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 16cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace base { 17cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class FilePath; 18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} // namespace base 19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace extensions { 21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class EventRouter; 22cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} // namespace extensions 23cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 24cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace chromeos { 25cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace file_system_provider { 26cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace operations { 27cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 28116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Opens a file for either read or write. The file must exist, otherwise the 29116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// operation will fail. Created per request. 30cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class OpenFile : public Operation { 31cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) public: 32cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) OpenFile(extensions::EventRouter* event_router, 33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const ProvidedFileSystemInfo& file_system_info, 34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const base::FilePath& file_path, 35cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) ProvidedFileSystemInterface::OpenFileMode mode, 36cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const ProvidedFileSystemInterface::OpenFileCallback& callback); 37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual ~OpenFile(); 38cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 39cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Operation overrides. 40cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool Execute(int request_id) OVERRIDE; 41cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void OnSuccess(int request_id, 42cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) scoped_ptr<RequestValue> result, 4346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) bool has_more) OVERRIDE; 44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void OnError(int request_id, 45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch scoped_ptr<RequestValue> result, 46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch base::File::Error error) OVERRIDE; 47cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 48cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) private: 49cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) base::FilePath file_path_; 50cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) ProvidedFileSystemInterface::OpenFileMode mode_; 51cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const ProvidedFileSystemInterface::OpenFileCallback callback_; 52cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 53cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(OpenFile); 54cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}; 55cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 56cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} // namespace operations 57cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} // namespace file_system_provider 58cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} // namespace chromeos 59cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 60cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_OPERATIONS_OPEN_FILE_H_ 61