| Index: content/browser/renderer_host/pepper/pepper_filesystem_provider_backend_chromeos.h
|
| diff --git a/content/browser/renderer_host/pepper/pepper_filesystem_provider_backend_chromeos.h b/content/browser/renderer_host/pepper/pepper_filesystem_provider_backend_chromeos.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9fac69b555f6631e4c2e2d580decb4f7fcde02eb
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/pepper/pepper_filesystem_provider_backend_chromeos.h
|
| @@ -0,0 +1,179 @@
|
| +// Copyright 2015 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 PEPPER_FILESYSTEM_PROVIDER_HOST_H
|
| +#define PEPPER_FILESYSTEM_PROVIDER_HOST_H
|
| +
|
| +#include <chrono>
|
| +#include <queue>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/callback.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "chrome/browser/chromeos/file_system_provider/file_system_plugin/plugin_operation_router.h"
|
| +#include "content/browser/renderer_host/pepper/pepper_filesystem_provider_host.h"
|
| +#include "content/common/content_export.h"
|
| +#include "ppapi/c/dev/ppb_filesystemprovider_dev.h"
|
| +#include "ppapi/c/pp_file_info.h"
|
| +#include "ppapi/host/host_message_context.h"
|
| +
|
| +
|
| +namespace content {
|
| +
|
| +class CONTENT_EXPORT PepperFilesystemProviderBackendChromeOS
|
| + : public PepperFilesystemProviderBackend
|
| + , public chromeos::file_system_provider::
|
| + PluginOperationRouter::PluginOperationRouterClient {
|
| + public:
|
| +
|
| + struct ProvidedFilesystemInfo{
|
| + ProvidedFilesystemInfo();
|
| + std::string filesystem_id;
|
| + std::string display_name;
|
| + std::string plugin_name;
|
| + bool writable;
|
| + int32_t opened_files_limit;
|
| + };
|
| + struct ShmBuffer {
|
| + ShmBuffer(uint32_t size, scoped_ptr<base::SharedMemory> shm);
|
| + ~ShmBuffer();
|
| + uint32_t size;
|
| + scoped_ptr<base::SharedMemory> shm;
|
| + };
|
| + // Waiting room for shared memory
|
| + class ShmChannelController{
|
| + public:
|
| + typedef base::Callback<bool(scoped_ptr<base::ListValue>)>
|
| + FlushRequestCallback;
|
| + ShmChannelController( uint32_t size, FlushRequestCallback callback );
|
| + ~ShmChannelController();
|
| + // This will discard the request if no room is found
|
| + bool EnqueueRequest(scoped_ptr<base::ListValue> response);
|
| + bool PushNextRequest();
|
| + bool AckLastPushedRequest();
|
| + private:
|
| + uint32_t size();
|
| + uint32_t max_size;
|
| + ScopedVector<base::ListValue> replies;
|
| + bool ready;
|
| + FlushRequestCallback callback;
|
| + };
|
| + public:
|
| + // Creates a new PepperFilesystemProviderBackendChromeOS
|
| + PepperFilesystemProviderBackendChromeOS(content::BrowserPpapiHost *host,
|
| + PP_Instance, PP_Resource);
|
| + ~PepperFilesystemProviderBackendChromeOS()override;
|
| + private:
|
| + // Handles the mount requests from plugins
|
| + int32_t SendMountRequest(
|
| + ppapi::host::HostMessageContext *context,
|
| + const base::ListValue&
|
| + /*std::string fsid,
|
| + std::string display_name,
|
| + bool writable,
|
| + int32_t opened_files_limit*/)override;
|
| + // Handles unmount requests from plugins
|
| + int32_t SendUnmountRequest(
|
| + ppapi::host::HostMessageContext* context,
|
| + const std::string& fsid )override;
|
| + // Handles plugin notifications. These are responses to browser request
|
| + int32_t OnPluginResponse(ppapi::host::HostMessageContext *context,
|
| + const base::ListValue &)override;
|
| + int32_t OnPluginWriteAck(ppapi::host::HostMessageContext *context)override;
|
| + int32_t OnPluginNotification(ppapi::host::HostMessageContext *context,
|
| + const base::ListValue &)override;
|
| + // Helper Function to Send a notification to the backend
|
| + static void SendNotificationOnUI(const ProvidedFilesystemInfo&,
|
| + scoped_ptr<base::ListValue>);
|
| + // Helper Functions that register desired events with
|
| + // the PluginEventRouter
|
| + void RegisterFilesystemListenedOperations();
|
| + void UnregisterFilesystemListenedOperations();
|
| +
|
| + // The next 2 functions are for the mount logic
|
| + static base::File::Error RegisterFilesystemOnUI(
|
| + ProvidedFilesystemInfo filesystem_info);
|
| + void MountReplyOnIO(
|
| + ppapi::host::ReplyMessageContext reply_msg,
|
| + ProvidedFilesystemInfo filesystem_info,
|
| + base::File::Error err );
|
| + // The next 2 functions are for the unmount logic
|
| + static base::File::Error UnregisterFilesystemOnUI(
|
| + ProvidedFilesystemInfo filesystem_info);
|
| + void UnmountReplyOnIO(
|
| + ppapi::host::ReplyMessageContext reply_msg,
|
| + base::File::Error err );
|
| +
|
| + // PluginOperationsRouterClient interface
|
| + void OnDispatchOperationRequest(
|
| + chromeos::file_system_provider::RequestType,
|
| + scoped_ptr<base::ListValue> request)override;
|
| +
|
| + // Composes success messages that are expected
|
| + // by the filesystem backend
|
| + static int32_t OnSuccessResponse(int operation,
|
| + const ProvidedFilesystemInfo& filesystem_info,
|
| + scoped_ptr<base::ListValue> response);
|
| + // Composes error messages that are expected
|
| + // by the filesystem backend
|
| + static int32_t OnErrorResponse(
|
| + const ProvidedFilesystemInfo& filesystem_info,
|
| + scoped_ptr<base::ListValue> response);
|
| +
|
| + // Utility function that is used for inserting the request payload into
|
| + // the shared memory and send it to the plugin
|
| + bool FlushRequest(scoped_ptr<base::ListValue> request);
|
| + // Initializes the shared memory buffer and notifies the plugin
|
| + bool InitializeMemoryBuffer( );
|
| + // Replaces a defined slot inside the list with a copied chunk
|
| + // from shared memory
|
| + bool AddFromSharedMemoryToMessage(base::ListValue& message);
|
| + // Extracts from the message a defined slot from inside the list
|
| + // and places it in memory.
|
| + bool AddFromMessageToSharedMemory(base::ListValue& message);
|
| + // Removes a custom header that it's use to make the processing easier
|
| + // and pre-processes the message
|
| + bool PreprocessMessage(base::ListValue& message,
|
| + bool& message_status,
|
| + int& operation_type);
|
| + void SendReadAck();
|
| + // The filesystem info
|
| + ProvidedFilesystemInfo filesystem_info_;
|
| + // Flag for status
|
| + bool mounted_;
|
| + // 1st: Read Buffer - kReaderBufferSize
|
| + // 2nd: Write Buffer - kWriterBufferSize
|
| + scoped_ptr<ShmBuffer> read_write_buffer_;
|
| + // Not owned. These are owned by the parent ResourceHost
|
| + ppapi::host::PpapiHost* host_;
|
| + PP_Resource resource_;
|
| + scoped_ptr<ShmChannelController> write_channel_controller_;
|
| + // Sabin Remove this
|
| + std::chrono::time_point<std::chrono::system_clock> time_stamp_;
|
| + base::WeakPtrFactory<PepperFilesystemProviderBackendChromeOS> weak_factory_;
|
| + DISALLOW_COPY_AND_ASSIGN(PepperFilesystemProviderBackendChromeOS);
|
| +};
|
| +
|
| +namespace filesystem_provider_internal {
|
| +struct MountOperationTranslator{
|
| + MountOperationTranslator(){}
|
| + ~MountOperationTranslator(){}
|
| +
|
| + static scoped_ptr<MountOperationTranslator> PopulateFromResponse(
|
| + const base::ListValue& request);
|
| + // The filesystem identifier of the filesystem related to this operation.
|
| + std::string file_system_id;
|
| + // The display name for the filesystem
|
| + std::string display_name;
|
| + // A flag that indicates if the filesystem is writable or not
|
| + bool writable;
|
| + // The opened files limit indicator. If 0 there is no file limit
|
| + int opened_files_limit;
|
| +};
|
| +} // namespace filesystem_provider_internal
|
| +} // namespace content
|
| +
|
| +#endif // PEPPER_FILESYSTEM_PROVIDER_HOST_H
|
| +
|
|
|