Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: components/nacl/renderer/manifest_service_channel.h

Issue 249183004: Implement open_resource in non-SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef COMPONENTS_NACL_RENDERER_MANIFEST_SERVICE_CHANNEL_H_ 5 #ifndef COMPONENTS_NACL_RENDERER_MANIFEST_SERVICE_CHANNEL_H_
6 #define COMPONENTS_NACL_RENDERER_MANIFEST_SERVICE_CHANNEL_H_ 6 #define COMPONENTS_NACL_RENDERER_MANIFEST_SERVICE_CHANNEL_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/platform_file.h"
13 #include "base/process/process.h"
14 #include "base/synchronization/lock.h"
11 #include "ipc/ipc_listener.h" 15 #include "ipc/ipc_listener.h"
12 16
13 namespace base { 17 namespace base {
14 class WaitableEvent; 18 class WaitableEvent;
15 } // namespace base 19 } // namespace base
16 20
17 namespace IPC { 21 namespace IPC {
18 struct ChannelHandle; 22 struct ChannelHandle;
19 class Message; 23 class Message;
20 class SyncChannel; 24 class SyncChannel;
21 } // namespace IPC 25 } // namespace IPC
22 26
23 namespace nacl { 27 namespace nacl {
24 28
25 class ManifestServiceChannel : public IPC::Listener { 29 class ManifestServiceChannel : public IPC::Listener {
26 public: 30 public:
31 typedef base::Callback<void(int32_t, const base::PlatformFile&)>
32 OpenResourceCallback;
33
27 class Delegate { 34 class Delegate {
28 public: 35 public:
29 virtual ~Delegate() {} 36 virtual ~Delegate() {}
30 37
31 // Called when PPAPI initialization in the NaCl plugin is finished. 38 // Called when PPAPI initialization in the NaCl plugin is finished.
32 virtual void StartupInitializationComplete() = 0; 39 virtual void StartupInitializationComplete() = 0;
33 40
34 // TODO(hidehiko): Add OpenResource() here. 41 // Called when irt_open_resource() is invoked in the NaCl plugin.
42 // Upon completion, callback is invoked with the platform file.
43 virtual void OpenResource(
44 const std::string& key,
45 const OpenResourceCallback& callback) = 0;
35 }; 46 };
36 47
37 ManifestServiceChannel( 48 ManifestServiceChannel(
38 const IPC::ChannelHandle& handle, 49 const IPC::ChannelHandle& handle,
39 const base::Callback<void(int32_t)>& connected_callback, 50 const base::Callback<void(int32_t)>& connected_callback,
40 scoped_ptr<Delegate> delegate, 51 scoped_ptr<Delegate> delegate,
41 base::WaitableEvent* waitable_event); 52 base::WaitableEvent* waitable_event);
42 virtual ~ManifestServiceChannel(); 53 virtual ~ManifestServiceChannel();
43 54
55 void Send(IPC::Message* message);
56
44 // Listener implementation. 57 // Listener implementation.
45 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
46 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 59 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
47 virtual void OnChannelError() OVERRIDE; 60 virtual void OnChannelError() OVERRIDE;
48 61
49 private: 62 private:
50 void OnStartupInitializationComplete(); 63 void OnStartupInitializationComplete();
64 void OnOpenResource(const std::string& key, IPC::Message* reply);
65 void DidOpenResource(IPC::Message* reply, int32_t pp_error,
66 const base::PlatformFile& platform_file);
67 base::ProcessHandle PeerHandle();
51 68
52 base::Callback<void(int32_t)> connected_callback_; 69 base::Callback<void(int32_t)> connected_callback_;
53 scoped_ptr<Delegate> delegate_; 70 scoped_ptr<Delegate> delegate_;
54 scoped_ptr<IPC::SyncChannel> channel_; 71 scoped_ptr<IPC::SyncChannel> channel_;
55 72
73 base::ProcessHandle peer_handle_;
74
75 // Note: This should remain the last member so it'll be destroyed and
76 // invalidate the weak pointers before any other members are destroyed.
77 base::WeakPtrFactory<ManifestServiceChannel> weak_ptr_factory_;
78
56 DISALLOW_COPY_AND_ASSIGN(ManifestServiceChannel); 79 DISALLOW_COPY_AND_ASSIGN(ManifestServiceChannel);
57 }; 80 };
58 81
59 } // namespace nacl 82 } // namespace nacl
60 83
61 #endif // COMPONENTS_NACL_RENDERER_MANIFEST_SERVICE_CHANNEL_H_ 84 #endif // COMPONENTS_NACL_RENDERER_MANIFEST_SERVICE_CHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698