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

Side by Side Diff: src/shared/ppapi_proxy/plugin_callback.h

Issue 6177007: ppapi_proxy: Support loading and reading urls. Proxy URLLoader.... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « src/shared/ppapi_proxy/nacl.scons ('k') | src/shared/ppapi_proxy/plugin_callback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2010 The Native Client 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 NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CALLBACK_H_ 5 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CALLBACK_H_
6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CALLBACK_H_ 6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CALLBACK_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "ppapi/c/pp_completion_callback.h" 10 #include "ppapi/c/pp_completion_callback.h"
11 11
12 namespace ppapi_proxy { 12 namespace ppapi_proxy {
13 13
14 // Maintains a table of PP_CompletionCallback objects and their respective 14 // Maintains a table of PP_CompletionCallback objects and their respective
15 // identifiers that can be used to retrieve the objects. 15 // identifiers that can be used to retrieve the objects.
16 class CompletionCallbackTable { 16 class CompletionCallbackTable {
17 public: 17 public:
18 CompletionCallbackTable(); 18 CompletionCallbackTable();
19 ~CompletionCallbackTable() {} 19 ~CompletionCallbackTable() {}
20 20
21 static CompletionCallbackTable* Get() { 21 static CompletionCallbackTable* Get() {
22 static CompletionCallbackTable table; 22 static CompletionCallbackTable table;
23 return &table; 23 return &table;
24 } 24 }
25 25
26 // Adds the given |callback|, generating and returning an identifier for it. 26 // Adds the given |callback| and optionally the associated |read_buffer|,
27 // generating and returning an identifier for it.
27 // If |callback| is NULL, then returns 0. 28 // If |callback| is NULL, then returns 0.
28 int32_t AddCallback(const PP_CompletionCallback& callback); 29 int32_t AddCallback(const PP_CompletionCallback& callback);
29 // Removes and returns the callback corresponding to the given |callback_id|. 30 int32_t AddCallback(const PP_CompletionCallback& callback, char* read_buffer);
31 // Removes and returns the callback and optionally the associated
32 // |read_buffer| corresponding to the given |callback_id|.
30 // If no callback is found, returns a NULL callback. 33 // If no callback is found, returns a NULL callback.
31 PP_CompletionCallback RemoveCallback(int32_t callback_id); 34 PP_CompletionCallback RemoveCallback(int32_t callback_id, char** read_buffer);
32 35
33 private: 36 private:
34 typedef std::map<int32_t, PP_CompletionCallback> CallbackTable; 37 struct CallbackInfo {
38 PP_CompletionCallback callback;
39 char* read_buffer; // To be used with callbacks invoked on byte reads.
40 };
41
42 typedef std::map<int32_t, CallbackInfo> CallbackTable;
35 CallbackTable table_; 43 CallbackTable table_;
36 int32_t next_id_; 44 int32_t next_id_;
37 }; 45 };
38 46
39 } // namespace ppapi_proxy 47 } // namespace ppapi_proxy
40 48
41 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CALLBACK_H_ 49 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_CALLBACK_H_
OLDNEW
« no previous file with comments | « src/shared/ppapi_proxy/nacl.scons ('k') | src/shared/ppapi_proxy/plugin_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698