content/gpu: Ownership and lifetime cleanup for CommandBufferProxyImpl.
[chromium-blink-merge.git] / content / renderer / pepper / pepper_file_system_host.h
blob23d7c49a2cb8061d2f29659382be60813dfd6906
1 // Copyright (c) 2013 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.
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_FILE_SYSTEM_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_FILE_SYSTEM_HOST_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/files/file.h"
12 #include "base/memory/weak_ptr.h"
13 #include "ppapi/c/pp_file_info.h"
14 #include "ppapi/c/private/ppb_isolated_file_system_private.h"
15 #include "ppapi/host/host_message_context.h"
16 #include "ppapi/host/resource_host.h"
17 #include "url/gurl.h"
19 namespace content {
21 class RendererPpapiHost;
23 class PepperFileSystemHost
24 : public ppapi::host::ResourceHost,
25 public base::SupportsWeakPtr<PepperFileSystemHost> {
26 public:
27 // Creates a new PepperFileSystemHost for a file system of a given |type|. The
28 // host will not be connected to any specific file system, and will need to
29 // subsequently be opened before use.
30 PepperFileSystemHost(RendererPpapiHost* host,
31 PP_Instance instance,
32 PP_Resource resource,
33 PP_FileSystemType type);
34 // Creates a new PepperFileSystemHost with an existing file system at the
35 // given |root_url| and of the given |type|. The file system must already be
36 // opened. Once created, the PepperFileSystemHost is already opened for use.
37 PepperFileSystemHost(RendererPpapiHost* host,
38 PP_Instance instance,
39 PP_Resource resource,
40 const GURL& root_url,
41 PP_FileSystemType type);
42 ~PepperFileSystemHost() override;
44 // ppapi::host::ResourceHost override.
45 int32_t OnResourceMessageReceived(
46 const IPC::Message& msg,
47 ppapi::host::HostMessageContext* context) override;
48 bool IsFileSystemHost() override;
50 // Supports FileRefs direct access on the host side.
51 PP_FileSystemType GetType() const { return type_; }
52 bool IsOpened() const { return opened_; }
53 GURL GetRootUrl() const { return root_url_; }
55 private:
56 // Callback for OpenFileSystem.
57 void DidOpenFileSystem(const std::string& name_unused, const GURL& root);
58 void DidFailOpenFileSystem(base::File::Error error);
60 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context,
61 int64_t expected_size);
62 int32_t OnHostMsgInitIsolatedFileSystem(
63 ppapi::host::HostMessageContext* context,
64 const std::string& fsid,
65 PP_IsolatedFileSystemType_Private type);
67 RendererPpapiHost* renderer_ppapi_host_;
68 ppapi::host::ReplyMessageContext reply_context_;
70 PP_FileSystemType type_;
71 bool opened_; // whether open is successful.
72 GURL root_url_;
73 bool called_open_; // whether open has been called.
75 base::WeakPtrFactory<PepperFileSystemHost> weak_factory_;
77 DISALLOW_COPY_AND_ASSIGN(PepperFileSystemHost);
80 } // namespace content
82 #endif // CONTENT_RENDERER_PEPPER_PEPPER_FILE_SYSTEM_HOST_H_