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

Side by Side Diff: ppapi/proxy/raw_var_data.h

Issue 1864293002: Convert //ppapi to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more nullptr Created 4 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
« no previous file with comments | « ppapi/proxy/proxy_channel.h ('k') | ppapi/proxy/raw_var_data.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_PROXY_RAW_VAR_DATA_H_ 5 #ifndef PPAPI_PROXY_RAW_VAR_DATA_H_
6 #define PPAPI_PROXY_RAW_VAR_DATA_H_ 6 #define PPAPI_PROXY_RAW_VAR_DATA_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "ppapi/c/pp_instance.h" 16 #include "ppapi/c/pp_instance.h"
17 #include "ppapi/c/pp_var.h" 17 #include "ppapi/c/pp_var.h"
18 #include "ppapi/proxy/ppapi_param_traits.h" 18 #include "ppapi/proxy/ppapi_param_traits.h"
19 #include "ppapi/proxy/ppapi_proxy_export.h" 19 #include "ppapi/proxy/ppapi_proxy_export.h"
20 #include "ppapi/proxy/serialized_handle.h" 20 #include "ppapi/proxy/serialized_handle.h"
21 21
22 namespace base { 22 namespace base {
23 class Pickle; 23 class Pickle;
24 class PickleIterator; 24 class PickleIterator;
25 } 25 }
(...skipping 23 matching lines...) Expand all
49 // 2 | var type | 49 // 2 | var type |
50 // | var data | 50 // | var data |
51 // | .... | 51 // | .... |
52 // 52 //
53 // Vars that reference other vars (such as Arrays or Dictionaries) use indices 53 // Vars that reference other vars (such as Arrays or Dictionaries) use indices
54 // into the message to denote which PP_Var is pointed to. 54 // into the message to denote which PP_Var is pointed to.
55 class PPAPI_PROXY_EXPORT RawVarDataGraph { 55 class PPAPI_PROXY_EXPORT RawVarDataGraph {
56 public: 56 public:
57 // Construct a RawVarDataGraph from a given root PP_Var. A null pointer 57 // Construct a RawVarDataGraph from a given root PP_Var. A null pointer
58 // is returned upon failure. 58 // is returned upon failure.
59 static scoped_ptr<RawVarDataGraph> Create(const PP_Var& var, 59 static std::unique_ptr<RawVarDataGraph> Create(const PP_Var& var,
60 PP_Instance instance); 60 PP_Instance instance);
61 61
62 // Constructs an empty RawVarDataGraph. 62 // Constructs an empty RawVarDataGraph.
63 RawVarDataGraph(); 63 RawVarDataGraph();
64 ~RawVarDataGraph(); 64 ~RawVarDataGraph();
65 65
66 // Construct a new PP_Var from the graph. All of the PP_Vars referenced by 66 // Construct a new PP_Var from the graph. All of the PP_Vars referenced by
67 // the returned PP_Var are also constructed. Each PP_Var created has a 67 // the returned PP_Var are also constructed. Each PP_Var created has a
68 // ref-count equal to the number of references it has in the graph of vars. 68 // ref-count equal to the number of references it has in the graph of vars.
69 // The returned var (the "root") has one additional reference. 69 // The returned var (the "root") has one additional reference.
70 PP_Var CreatePPVar(PP_Instance instance); 70 PP_Var CreatePPVar(PP_Instance instance);
71 71
72 // Write the graph to a message using the given HandleWriter. 72 // Write the graph to a message using the given HandleWriter.
73 void Write(base::Pickle* m, const HandleWriter& handle_writer); 73 void Write(base::Pickle* m, const HandleWriter& handle_writer);
74 74
75 // Create a RawVarDataGraph from the given message. 75 // Create a RawVarDataGraph from the given message.
76 static scoped_ptr<RawVarDataGraph> Read(const base::Pickle* m, 76 static std::unique_ptr<RawVarDataGraph> Read(const base::Pickle* m,
77 base::PickleIterator* iter); 77 base::PickleIterator* iter);
78 78
79 // Returns a vector of SerializedHandles associated with this RawVarDataGraph. 79 // Returns a vector of SerializedHandles associated with this RawVarDataGraph.
80 // Ownership of the pointers remains with the elements of the RawVarDataGraph. 80 // Ownership of the pointers remains with the elements of the RawVarDataGraph.
81 std::vector<SerializedHandle*> GetHandles(); 81 std::vector<SerializedHandle*> GetHandles();
82 82
83 // Sets the threshold size at which point we switch from transmitting 83 // Sets the threshold size at which point we switch from transmitting
84 // array buffers in IPC messages to using shared memory. This is only used 84 // array buffers in IPC messages to using shared memory. This is only used
85 // for testing purposes where we need to transmit small buffers using shmem 85 // for testing purposes where we need to transmit small buffers using shmem
86 // (in order to have fast tests). 86 // (in order to have fast tests).
87 static void SetMinimumArrayBufferSizeForShmemForTest(uint32_t threshold); 87 static void SetMinimumArrayBufferSizeForShmemForTest(uint32_t threshold);
88 88
89 private: 89 private:
90 // A list of the nodes in the graph. 90 // A list of the nodes in the graph.
91 std::vector<scoped_ptr<RawVarData>> data_; 91 std::vector<std::unique_ptr<RawVarData>> data_;
92 92
93 DISALLOW_COPY_AND_ASSIGN(RawVarDataGraph); 93 DISALLOW_COPY_AND_ASSIGN(RawVarDataGraph);
94 }; 94 };
95 95
96 // Abstract base class for the data contained in a PP_Var. 96 // Abstract base class for the data contained in a PP_Var.
97 class RawVarData { 97 class RawVarData {
98 public: 98 public:
99 // Create a new, empty RawVarData for the given type. 99 // Create a new, empty RawVarData for the given type.
100 static RawVarData* Create(PP_VarType type); 100 static RawVarData* Create(PP_VarType type);
101 RawVarData(); 101 RawVarData();
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // Pending resource host ID in the renderer. 288 // Pending resource host ID in the renderer.
289 int pending_renderer_host_id_; 289 int pending_renderer_host_id_;
290 290
291 // Pending resource host ID in the browser. 291 // Pending resource host ID in the browser.
292 int pending_browser_host_id_; 292 int pending_browser_host_id_;
293 293
294 // A message containing information about how to create a plugin-side 294 // A message containing information about how to create a plugin-side
295 // resource. The message type will vary based on the resource type, and will 295 // resource. The message type will vary based on the resource type, and will
296 // usually contain a pending resource host ID, and other required information. 296 // usually contain a pending resource host ID, and other required information.
297 // If the resource was created directly, this is NULL. 297 // If the resource was created directly, this is NULL.
298 scoped_ptr<IPC::Message> creation_message_; 298 std::unique_ptr<IPC::Message> creation_message_;
299 }; 299 };
300 300
301 } // namespace proxy 301 } // namespace proxy
302 } // namespace ppapi 302 } // namespace ppapi
303 303
304 #endif // PPAPI_PROXY_RAW_VAR_DATA_H_ 304 #endif // PPAPI_PROXY_RAW_VAR_DATA_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/proxy_channel.h ('k') | ppapi/proxy/raw_var_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698