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

Side by Side Diff: ppapi/cpp/instance.h

Issue 9381010: Convert resources to take an instance key instead of an Instance*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 PPAPI_CPP_INSTANCE_H_ 5 #ifndef PPAPI_CPP_INSTANCE_H_
6 #define PPAPI_CPP_INSTANCE_H_ 6 #define PPAPI_CPP_INSTANCE_H_
7 7
8 /// @file 8 /// @file
9 /// This file defines the C++ wrapper for an instance. 9 /// This file defines the C++ wrapper for an instance.
10 10
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 13
14 #include "ppapi/c/pp_instance.h" 14 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_stdint.h" 16 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/cpp/instance_handle.h"
17 #include "ppapi/cpp/view.h" 18 #include "ppapi/cpp/view.h"
18 19
19 struct PP_InputEvent; 20 struct PP_InputEvent;
20 21
21 /// The C++ interface to the Pepper API. 22 /// The C++ interface to the Pepper API.
22 namespace pp { 23 namespace pp {
23 24
24 class Graphics2D; 25 class Graphics2D;
25 class Graphics3D; 26 class Graphics3D;
26 class InputEvent; 27 class InputEvent;
28 class InstanceHandle;
27 class Rect; 29 class Rect;
28 class URLLoader; 30 class URLLoader;
29 class Var; 31 class Var;
30 32
31 class Instance { 33 class Instance {
32 public: 34 public:
33 /// Default constructor. Construction of an instance should only be done in 35 /// Default constructor. Construction of an instance should only be done in
34 /// response to a browser request in <code>Module::CreateInstance</code>. 36 /// response to a browser request in <code>Module::CreateInstance</code>.
35 /// Otherwise, the instance will lack the proper bookkeeping in the browser 37 /// Otherwise, the instance will lack the proper bookkeeping in the browser
36 /// and in the C++ wrapper. 38 /// and in the C++ wrapper.
(...skipping 16 matching lines...) Expand all
53 /// file writes from this destructor since they will be immediately canceled. 55 /// file writes from this destructor since they will be immediately canceled.
54 /// 56 ///
55 /// <strong>Note:</strong> This function may be skipped in certain 57 /// <strong>Note:</strong> This function may be skipped in certain
56 /// call so the instance can perform cleanup-related tasks. Once this function 58 /// call so the instance can perform cleanup-related tasks. Once this function
57 /// returns, the <code>PP_Instance</code> handle will be invalid. This means 59 /// returns, the <code>PP_Instance</code> handle will be invalid. This means
58 /// that you can't do any asynchronous operations such as network requests or 60 /// that you can't do any asynchronous operations such as network requests or
59 /// file writes from this destructor since they will be immediately canceled. 61 /// file writes from this destructor since they will be immediately canceled.
60 virtual ~Instance(); 62 virtual ~Instance();
61 63
62 /// This function returns the <code>PP_Instance</code> identifying this 64 /// This function returns the <code>PP_Instance</code> identifying this
63 /// object. When using the PPAPI C++ wrappers this is not normally necessary, 65 /// object.
64 /// but is required when using the lower-level C APIs.
65 /// 66 ///
66 /// @return A <code>PP_Instance</code> identifying this object. 67 /// @return A <code>PP_Instance</code> identifying this object.
67 PP_Instance pp_instance() const { return pp_instance_; } 68 PP_Instance pp_instance() const { return pp_instance_; }
68 69
69 /// Init() initializes this instance with the provided arguments. This 70 /// Init() initializes this instance with the provided arguments. This
70 /// function will be called immediately after the instance object is 71 /// function will be called immediately after the instance object is
71 /// constructed. 72 /// constructed.
72 /// 73 ///
73 /// @param[in] argc The number of arguments contained in <code>argn</code> 74 /// @param[in] argc The number of arguments contained in <code>argn</code>
74 /// and <code>argv</code>. 75 /// and <code>argv</code>.
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 /// get the C calls in the first place. 480 /// get the C calls in the first place.
480 /// 481 ///
481 /// Refer to RemovePerInstanceObject() and GetPerInstanceObject() for further 482 /// Refer to RemovePerInstanceObject() and GetPerInstanceObject() for further
482 /// information. 483 /// information.
483 /// 484 ///
484 /// @param[in] interface_name The name of the interface to associate with the 485 /// @param[in] interface_name The name of the interface to associate with the
485 /// instance 486 /// instance
486 /// @param[in] object 487 /// @param[in] object
487 void AddPerInstanceObject(const std::string& interface_name, void* object); 488 void AddPerInstanceObject(const std::string& interface_name, void* object);
488 489
489 // {PENDING: summarize Remove method here} 490 /// Static version of AddPerInstanceObject that takes an InstanceHandle. As wi th
dmichael (off chromium) 2012/02/21 23:38:02 nit: >80 char
491 /// all other instance functions, this must only be called on the main thread.
492 static void AddPerInstanceObject(const InstanceHandle& instance,
493 const std::string& interface_name,
494 void* object);
495
496 /// {PENDING: summarize Remove method here}
dmichael (off chromium) 2012/02/21 23:38:02 nit: jond made that // instead of /// to keep it o
490 /// 497 ///
491 /// Refer to AddPerInstanceObject() for further information. 498 /// Refer to AddPerInstanceObject() for further information.
492 /// 499 ///
493 /// @param[in] interface_name The name of the interface to associate with the 500 /// @param[in] interface_name The name of the interface to associate with the
494 /// instance 501 /// instance
495 /// @param[in] object 502 /// @param[in] object
496 void RemovePerInstanceObject(const std::string& interface_name, void* object); 503 void RemovePerInstanceObject(const std::string& interface_name, void* object);
497 504
505 /// Static version of AddPerInstanceObject that takes an InstanceHandle. As wi th
dmichael (off chromium) 2012/02/21 23:38:02 >80 char
506 /// all other instance functions, this must only be called on the main thread.
507 static void RemovePerInstanceObject(const InstanceHandle& instance,
508 const std::string& interface_name,
509 void* object);
510
498 /// Look up an object previously associated with an instance. Returns NULL 511 /// Look up an object previously associated with an instance. Returns NULL
499 /// if the instance is invalid or there is no object for the given interface 512 /// if the instance is invalid or there is no object for the given interface
500 /// name on the instance. 513 /// name on the instance.
501 /// 514 ///
502 /// Refer to AddPerInstanceObject() for further information. 515 /// Refer to AddPerInstanceObject() for further information.
503 /// 516 ///
504 /// @param[in] instance 517 /// @param[in] instance
505 /// @param[in] interface_name The name of the interface to associate with the 518 /// @param[in] interface_name The name of the interface to associate with the
506 /// instance. 519 /// instance.
507 static void* GetPerInstanceObject(PP_Instance instance, 520 static void* GetPerInstanceObject(PP_Instance instance,
508 const std::string& interface_name); 521 const std::string& interface_name);
509 522
510 private: 523 private:
511 PP_Instance pp_instance_; 524 PP_Instance pp_instance_;
512 525
513 typedef std::map<std::string, void*> InterfaceNameToObjectMap; 526 typedef std::map<std::string, void*> InterfaceNameToObjectMap;
514 InterfaceNameToObjectMap interface_name_to_objects_; 527 InterfaceNameToObjectMap interface_name_to_objects_;
515 }; 528 };
516 529
517 } // namespace pp 530 } // namespace pp
518 531
519 #endif // PPAPI_CPP_INSTANCE_H_ 532 #endif // PPAPI_CPP_INSTANCE_H_
OLDNEW
« no previous file with comments | « ppapi/cpp/input_event.cc ('k') | ppapi/cpp/instance.cc » ('j') | ppapi/cpp/instance.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698