Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_RESOURCE_H_ | 5 #ifndef PPAPI_CPP_RESOURCE_H_ |
| 6 #define PPAPI_CPP_RESOURCE_H_ | 6 #define PPAPI_CPP_RESOURCE_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_resource.h" | 8 #include "ppapi/c/pp_resource.h" |
| 9 | 9 |
| 10 /// @file | |
| 11 /// This file defines a Resource type representing data associated | |
| 12 /// with the module. | |
| 10 namespace pp { | 13 namespace pp { |
| 11 | 14 |
| 12 // Base class for refcounted plugin resources. | 15 /// A reference counted module resource. |
| 13 class Resource { | 16 class Resource { |
| 14 public: | 17 public: |
| 18 | |
| 19 /// The default constructor. | |
| 15 Resource(); | 20 Resource(); |
| 21 | |
| 22 /// A constructor accepting a reference to a Resource. | |
|
dmichael (off chromium)
2011/06/07 05:01:23
You can just say 'The copy constructor.'
jond
2011/06/07 16:41:00
I changed this to "A constructor fo copying a reso
dmichael (off chromium)
2011/06/07 20:45:26
Above it says 'The default constructor.' The copy
| |
| 23 /// | |
| 24 /// @param[in] other A Resource. | |
| 16 Resource(const Resource& other); | 25 Resource(const Resource& other); |
| 17 | 26 |
| 27 /// Destructor. | |
| 18 virtual ~Resource(); | 28 virtual ~Resource(); |
| 19 | 29 |
| 30 /// This function assigns one Resource to another Resource. | |
| 31 /// | |
| 32 /// @param[in] other A Resource. | |
| 33 /// @return A Resource containing the assigned Resource. | |
| 20 Resource& operator=(const Resource& other); | 34 Resource& operator=(const Resource& other); |
| 21 | 35 |
| 22 // Returns true if the given resource is invalid or uninitialized. | 36 /// This functions determiens if this resource is invalid or |
|
dmichael (off chromium)
2011/06/07 05:01:23
I liked the original wording a little better. if
jond
2011/06/07 16:41:00
I'm trying to be consistent and all these sentence
| |
| 37 /// uninitialized. | |
| 38 /// | |
| 39 /// @return true if this resource is invalid or uninitialized. | |
| 23 bool is_null() const { return !pp_resource_; } | 40 bool is_null() const { return !pp_resource_; } |
| 24 | 41 |
| 25 PP_Resource pp_resource() const { return pp_resource_; } | 42 PP_Resource pp_resource() const { return pp_resource_; } |
| 26 | 43 |
| 27 // Releases ownership of the PP_Resource and returns it to the caller. | 44 /// This function releases ownership of this reource and returns it to the |
|
dmichael (off chromium)
2011/06/07 05:01:23
reource->resource
jond
2011/06/07 16:41:00
Done.
jond
2011/06/07 16:41:00
Done.
| |
| 28 // Note the the reference count on the resource is unchanged and the caller | 45 /// caller. |
| 29 // needs to release the resource. | 46 /// |
| 47 /// Note that the reference count on the resource is unchanged and the caller | |
| 48 /// needs to release the resource. | |
| 49 /// | |
| 50 /// @return The detached PP_Resource. | |
| 30 PP_Resource detach(); | 51 PP_Resource detach(); |
| 31 | 52 |
| 32 protected: | 53 protected: |
| 33 // This constructor is used when we've gotten a PP_Resource as a return value | 54 /// A constructer used when a PP_Resource is provided as a return value |
|
dmichael (off chromium)
2011/06/07 05:01:23
constructer->constructor
jond
2011/06/07 16:41:00
Done.
| |
| 34 // that we need to addref. | 55 /// that we need to provide a reference. |
|
dmichael (off chromium)
2011/06/07 05:01:23
change to 'whose reference count we need to increm
jond
2011/06/07 16:41:00
Done.
jond
2011/06/07 16:41:00
Done.
| |
| 56 /// | |
| 57 /// @param[in] resource A PP_Resource. | |
| 35 explicit Resource(PP_Resource resource); | 58 explicit Resource(PP_Resource resource); |
| 36 | 59 |
| 37 // Called by derived class' constructors to initialize this Resource with | 60 /// This function is called by derived class' constructors to initialize this |
| 38 // a PP_Resource that has already been AddRef'ed. It also assumes this object | 61 /// Resource with a PP_Resource that has already received a reference using |
|
dmichael (off chromium)
2011/06/07 05:01:23
'received a reference'->'had its reference count i
jond
2011/06/07 16:41:00
Done.
jond
2011/06/07 16:41:00
Done.
| |
| 39 // has no current resource. | 62 /// Core::AddRefResource. It also assumes this object has no current resource. |
| 40 // | 63 /// |
| 41 // The intended usage is that the derived class constructor will call the | 64 /// The intended usage is that the derived class constructor will call the |
| 42 // default Resource constructor, then make a call to create a resource. It | 65 /// default Resource constructor, then make a call to create a resource. It |
| 43 // then wants to assign the new resource (which, since it was returned by the | 66 /// then wants to assign the new resource (which, since it was returned by the |
| 44 // browser, is already AddRef'ed). | 67 /// browser, is already AddRef'ed). |
| 68 /// | |
| 69 /// @param[in] resource A PP_Resource. | |
| 45 void PassRefFromConstructor(PP_Resource resource); | 70 void PassRefFromConstructor(PP_Resource resource); |
| 46 | 71 |
| 47 private: | 72 private: |
| 48 PP_Resource pp_resource_; | 73 PP_Resource pp_resource_; |
| 49 }; | 74 }; |
| 50 | 75 |
| 51 } // namespace pp | 76 } // namespace pp |
| 52 | 77 |
| 53 inline bool operator==(const pp::Resource& lhs, const pp::Resource& rhs) { | 78 inline bool operator==(const pp::Resource& lhs, const pp::Resource& rhs) { |
| 54 return lhs.pp_resource() == rhs.pp_resource(); | 79 return lhs.pp_resource() == rhs.pp_resource(); |
| 55 } | 80 } |
| 56 | 81 |
| 57 #endif // PPAPI_CPP_RESOURCE_H_ | 82 #endif // PPAPI_CPP_RESOURCE_H_ |
| OLD | NEW |