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

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

Issue 9815025: PPAPI: Clean up documentation for InstanceHandle and PASS_REF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | « no previous file | ppapi/cpp/pass_ref.h » ('j') | ppapi/cpp/pass_ref.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_HANDLE_H_ 5 #ifndef PPAPI_CPP_INSTANCE_HANDLE_H_
6 #define PPAPI_CPP_INSTANCE_HANDLE_H_ 6 #define PPAPI_CPP_INSTANCE_HANDLE_H_
7 7
8 #include "ppapi/c/pp_instance.h" 8 #include "ppapi/c/pp_instance.h"
9 9
10
11 /// @file
12 /// This file defines an instance handle used to identify an instance in a
13 /// constructor for a resource.
10 namespace pp { 14 namespace pp {
11 15
12 class Instance; 16 class Instance;
13 17
14 /// An instance handle identifies an instance in a constructor for a resource. 18 /// An instance handle identifies an instance in a constructor for a resource.
15 /// Its existence solves two different problems: 19 /// This class solves two different problems:
16 /// 20 ///
17 /// A pp::Instance objects' lifetime is managed by the system on the main thread 21 /// 1. A pp::Instance objects' lifetime is managed by the system on the main
18 /// of the plugin. This means that it may get destroyed at any time based on 22 /// thread of the module. This means that it may get destroyed at any time
dmichael (off chromium) 2012/03/23 21:05:00 how about if we say "main pepper thread."
jond 2012/03/26 16:43:51 Done.
19 /// something that happens on the web page. This means that it's never OK to 23 /// based on something that happens on the web page. So, it's never good to
dmichael (off chromium) 2012/03/23 21:05:00 So->Therefore ? "never good" doesn't give the righ
jond 2012/03/26 16:43:51 Agreed. I just didn't want to change the technical
20 /// refer to a pp::Instance object on a background thread. So we need to pass 24 /// refer to a <code>pp::Instance</code> object on a background thread.
21 /// some kind of identifier instead to resource constructors so that they may 25 /// Instead, we need to pass some kind of identifier to resource constructors
22 /// safely be used on background threads. If the instance becomes invalid, the 26 /// so that they may safely be used on background threads. If the instance
23 /// resource creation will fail on the background thread, but it won't crash. 27 /// becomes invalid, the resource creation will fail on the background thread,
28 /// but it won't crash.
24 /// 29 ///
25 /// Background: PP_Instance would be a good identifier to use for this case. 30 /// 2. <code>PP_Instance</code> is a good identifier to use for this case.
dmichael (off chromium) 2012/03/23 21:05:00 is->would be ? (If it was a good identifier for t
jond 2012/03/26 16:43:51 Changing to "would be" seems okay to me. I made an
26 /// However, using it in the constructor to resources is problematic. 31 /// However, using it in the constructor to resources is problematic.
27 /// PP_Instance is just a typedef for an integer, as is a PP_Resource. Many 32 /// <code>PP_Instance</code> is just a typedef for an integer, as is a
28 /// resources have alternate constructors that just take an existing 33 /// <code>PP_Resource</code>. Many resources have alternate constructors that
29 /// PP_Resource, so the constructors would be ambiguous. Having this wrapper 34 /// just take an existing <code>PP_Resource</code>, so the constructors would
30 /// around a PP_Instance prevents this ambiguity, and also gives us a nice 35 /// be ambiguous. Having this wrapper around a <code>PP_Instance</code>
31 /// place to consolidate an implicit conversion from pp::Instance* for prettier 36 /// prevents this ambiguity, and also provides a nice place to consolidate an
32 /// code on the main thread (you can just pass "this" to resource constructors 37 /// implicit conversion from <code>pp::Instance*</code> for prettier code on
33 /// in your instance objects). 38 /// the main thread (you can just pass "this" to resource constructors in your
39 /// instance objects).
34 /// 40 ///
35 /// So you should always pass InstanceHandles to background threads instead of 41 /// You should always pass an <code>InstanceHandle</code> to background threads
36 /// a pp::Instance, and use them in resource constructors and code that may be 42 /// instead of a <code>pp::Instance</code>, and use them in resource
37 /// used from background threads. 43 /// constructors and code that may be used from background threads.
38 class InstanceHandle { 44 class InstanceHandle {
39 public: 45 public:
40 /// Implicit constructor for converting a pp::Instance to an instance handle. 46 /// Implicit constructor for converting a <code>pp::Instance</code> to an
47 /// instance handle.
48 ///
49 /// @param[in] instance The instance with which this
50 /// <code>InstanceHandle</code> will be associated.
41 InstanceHandle(Instance* instance); 51 InstanceHandle(Instance* instance);
42 52
43 /// Explicitly convert a PP_Instance to an instance handle. This should not 53 /// This constructor explicitly converts a <code>PP_Instance</code> to an
44 /// be implicit because it can make some resource constructors ambiguous. 54 /// instance handle. This should not be implicit because it can make some
45 /// PP_Instance is just a typedef for an integer, as is PP_Resource, so the 55 /// resource constructors ambiguous. <code>PP_Instance</code> is just a
46 /// compiler can get confused between the two. 56 /// typedef for an integer, as is <code>PP_Resource</code>, so the compiler
57 /// can get confused between the two.
58 ///
59 /// @param[in] pp_instance The instance with which this
60 /// <code>InstanceHandle</code> will be associated.
47 explicit InstanceHandle(PP_Instance pp_instance) 61 explicit InstanceHandle(PP_Instance pp_instance)
48 : pp_instance_(pp_instance) {} 62 : pp_instance_(pp_instance) {}
49 63
64 /// The pp_instance() function returns the internal instance handle.
dmichael (off chromium) 2012/03/23 21:05:00 "instance handle" -> "PP_Instance" (not wrong, but
jond 2012/03/26 16:43:51 Done.
65 ///
66 /// @return A <code>PP_Instance</code> internal instance handle.
50 PP_Instance pp_instance() const { return pp_instance_; } 67 PP_Instance pp_instance() const { return pp_instance_; }
51 68
52 private: 69 private:
53 PP_Instance pp_instance_; 70 PP_Instance pp_instance_;
54 }; 71 };
55 72
56 } // namespace pp 73 } // namespace pp
57 74
58 #endif // PPAPI_CPP_INSTANCE_HANDLE_H_ 75 #endif // PPAPI_CPP_INSTANCE_HANDLE_H_
OLDNEW
« no previous file with comments | « no previous file | ppapi/cpp/pass_ref.h » ('j') | ppapi/cpp/pass_ref.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698