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

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

Issue 818833004: Remove deprecated methods from Pickle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 12 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.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 "content/public/common/url_constants.h" 7 #include "content/public/common/url_constants.h"
8 #include "content/public/renderer/render_thread.h" 8 #include "content/public/renderer/render_thread.h"
9 #include "extensions/common/extension.h" 9 #include "extensions/common/extension.h"
10 #include "extensions/common/extension_set.h" 10 #include "extensions/common/extension_set.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Now map in the rest of the block. 103 // Now map in the rest of the block.
104 int pickle_size = sizeof(Pickle::Header) + pickle_header->payload_size; 104 int pickle_size = sizeof(Pickle::Header) + pickle_header->payload_size;
105 shared_memory_->Unmap(); 105 shared_memory_->Unmap();
106 if (!shared_memory_->Map(pickle_size)) 106 if (!shared_memory_->Map(pickle_size))
107 return false; 107 return false;
108 108
109 // Unpickle scripts. 109 // Unpickle scripts.
110 size_t num_scripts = 0; 110 size_t num_scripts = 0;
111 Pickle pickle(reinterpret_cast<char*>(shared_memory_->memory()), pickle_size); 111 Pickle pickle(reinterpret_cast<char*>(shared_memory_->memory()), pickle_size);
112 PickleIterator iter(pickle); 112 PickleIterator iter(pickle);
113 CHECK(pickle.ReadSizeT(&iter, &num_scripts)); 113 CHECK(iter.ReadSizeT(&num_scripts));
114 114
115 scripts_.clear(); 115 scripts_.clear();
116 scripts_.reserve(num_scripts); 116 scripts_.reserve(num_scripts);
117 for (size_t i = 0; i < num_scripts; ++i) { 117 for (size_t i = 0; i < num_scripts; ++i) {
118 scoped_ptr<UserScript> script(new UserScript()); 118 scoped_ptr<UserScript> script(new UserScript());
119 script->Unpickle(pickle, &iter); 119 script->Unpickle(pickle, &iter);
120 120
121 // Note that this is a pointer into shared memory. We don't own it. It gets 121 // Note that this is a pointer into shared memory. We don't own it. It gets
122 // cleared up when the last renderer or browser process drops their 122 // cleared up when the last renderer or browser process drops their
123 // reference to the shared memory. 123 // reference to the shared memory.
124 for (size_t j = 0; j < script->js_scripts().size(); ++j) { 124 for (size_t j = 0; j < script->js_scripts().size(); ++j) {
125 const char* body = NULL; 125 const char* body = NULL;
126 int body_length = 0; 126 int body_length = 0;
127 CHECK(pickle.ReadData(&iter, &body, &body_length)); 127 CHECK(iter.ReadData(&body, &body_length));
128 script->js_scripts()[j].set_external_content( 128 script->js_scripts()[j].set_external_content(
129 base::StringPiece(body, body_length)); 129 base::StringPiece(body, body_length));
130 } 130 }
131 for (size_t j = 0; j < script->css_scripts().size(); ++j) { 131 for (size_t j = 0; j < script->css_scripts().size(); ++j) {
132 const char* body = NULL; 132 const char* body = NULL;
133 int body_length = 0; 133 int body_length = 0;
134 CHECK(pickle.ReadData(&iter, &body, &body_length)); 134 CHECK(iter.ReadData(&body, &body_length));
135 script->css_scripts()[j].set_external_content( 135 script->css_scripts()[j].set_external_content(
136 base::StringPiece(body, body_length)); 136 base::StringPiece(body, body_length));
137 } 137 }
138 138
139 if (only_inject_incognito && !script->is_incognito_enabled()) 139 if (only_inject_incognito && !script->is_incognito_enabled())
140 continue; // This script shouldn't run in an incognito tab. 140 continue; // This script shouldn't run in an incognito tab.
141 141
142 scripts_.push_back(script.release()); 142 scripts_.push_back(script.release());
143 } 143 }
144 144
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 injector.Pass(), 212 injector.Pass(),
213 web_frame->toWebLocalFrame(), 213 web_frame->toWebLocalFrame(),
214 extension->id(), 214 extension->id(),
215 run_location, 215 run_location,
216 tab_id)); 216 tab_id));
217 } 217 }
218 return injection.Pass(); 218 return injection.Pass();
219 } 219 }
220 220
221 } // namespace extensions 221 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/user_script.cc ('k') | gpu/ipc/gpu_command_buffer_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698