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

Side by Side Diff: extensions/renderer/user_script_set.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | « extensions/common/user_script_unittest.cc ('k') | gpu/ipc/gpu_command_buffer_traits.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "extensions/renderer/user_script_set.h" 5 #include "extensions/renderer/user_script_set.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "content/public/common/url_constants.h" 8 #include "content/public/common/url_constants.h"
9 #include "content/public/renderer/render_thread.h" 9 #include "content/public/renderer/render_thread.h"
10 #include "extensions/common/extension.h" 10 #include "extensions/common/extension.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 bool whitelisted_only) { 91 bool whitelisted_only) {
92 bool only_inject_incognito = 92 bool only_inject_incognito =
93 ExtensionsRendererClient::Get()->IsIncognitoProcess(); 93 ExtensionsRendererClient::Get()->IsIncognitoProcess();
94 94
95 // Create the shared memory object (read only). 95 // Create the shared memory object (read only).
96 shared_memory_.reset(new base::SharedMemory(shared_memory, true)); 96 shared_memory_.reset(new base::SharedMemory(shared_memory, true));
97 if (!shared_memory_.get()) 97 if (!shared_memory_.get())
98 return false; 98 return false;
99 99
100 // First get the size of the memory block. 100 // First get the size of the memory block.
101 if (!shared_memory_->Map(sizeof(Pickle::Header))) 101 if (!shared_memory_->Map(sizeof(base::Pickle::Header)))
102 return false; 102 return false;
103 Pickle::Header* pickle_header = 103 base::Pickle::Header* pickle_header =
104 reinterpret_cast<Pickle::Header*>(shared_memory_->memory()); 104 reinterpret_cast<base::Pickle::Header*>(shared_memory_->memory());
105 105
106 // Now map in the rest of the block. 106 // Now map in the rest of the block.
107 int pickle_size = sizeof(Pickle::Header) + pickle_header->payload_size; 107 int pickle_size = sizeof(base::Pickle::Header) + pickle_header->payload_size;
108 shared_memory_->Unmap(); 108 shared_memory_->Unmap();
109 if (!shared_memory_->Map(pickle_size)) 109 if (!shared_memory_->Map(pickle_size))
110 return false; 110 return false;
111 111
112 // Unpickle scripts. 112 // Unpickle scripts.
113 size_t num_scripts = 0; 113 size_t num_scripts = 0;
114 Pickle pickle(reinterpret_cast<char*>(shared_memory_->memory()), pickle_size); 114 base::Pickle pickle(reinterpret_cast<char*>(shared_memory_->memory()),
115 PickleIterator iter(pickle); 115 pickle_size);
116 base::PickleIterator iter(pickle);
116 CHECK(iter.ReadSizeT(&num_scripts)); 117 CHECK(iter.ReadSizeT(&num_scripts));
117 118
118 scripts_.clear(); 119 scripts_.clear();
119 scripts_.reserve(num_scripts); 120 scripts_.reserve(num_scripts);
120 for (size_t i = 0; i < num_scripts; ++i) { 121 for (size_t i = 0; i < num_scripts; ++i) {
121 scoped_ptr<UserScript> script(new UserScript()); 122 scoped_ptr<UserScript> script(new UserScript());
122 script->Unpickle(pickle, &iter); 123 script->Unpickle(pickle, &iter);
123 124
124 // Note that this is a pointer into shared memory. We don't own it. It gets 125 // Note that this is a pointer into shared memory. We don't own it. It gets
125 // cleared up when the last renderer or browser process drops their 126 // cleared up when the last renderer or browser process drops their
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 injector.Pass(), 239 injector.Pass(),
239 web_frame->toWebLocalFrame(), 240 web_frame->toWebLocalFrame(),
240 injection_host.Pass(), 241 injection_host.Pass(),
241 run_location, 242 run_location,
242 tab_id)); 243 tab_id));
243 } 244 }
244 return injection.Pass(); 245 return injection.Pass();
245 } 246 }
246 247
247 } // namespace extensions 248 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/user_script_unittest.cc ('k') | gpu/ipc/gpu_command_buffer_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698