| OLD | NEW |
| 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 #include "chrome/renderer/extensions/user_script_slave.h" | 5 #include "chrome/renderer/extensions/user_script_slave.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 Pickle::Header* pickle_header = | 148 Pickle::Header* pickle_header = |
| 149 reinterpret_cast<Pickle::Header*>(shared_memory_->memory()); | 149 reinterpret_cast<Pickle::Header*>(shared_memory_->memory()); |
| 150 | 150 |
| 151 // Now map in the rest of the block. | 151 // Now map in the rest of the block. |
| 152 int pickle_size = sizeof(Pickle::Header) + pickle_header->payload_size; | 152 int pickle_size = sizeof(Pickle::Header) + pickle_header->payload_size; |
| 153 shared_memory_->Unmap(); | 153 shared_memory_->Unmap(); |
| 154 if (!shared_memory_->Map(pickle_size)) | 154 if (!shared_memory_->Map(pickle_size)) |
| 155 return false; | 155 return false; |
| 156 | 156 |
| 157 // Unpickle scripts. | 157 // Unpickle scripts. |
| 158 void* iter = NULL; | |
| 159 size_t num_scripts = 0; | 158 size_t num_scripts = 0; |
| 160 Pickle pickle(reinterpret_cast<char*>(shared_memory_->memory()), | 159 Pickle pickle(reinterpret_cast<char*>(shared_memory_->memory()), |
| 161 pickle_size); | 160 pickle_size); |
| 161 PickleIterator iter(pickle); |
| 162 pickle.ReadSize(&iter, &num_scripts); | 162 pickle.ReadSize(&iter, &num_scripts); |
| 163 | 163 |
| 164 scripts_.reserve(num_scripts); | 164 scripts_.reserve(num_scripts); |
| 165 for (size_t i = 0; i < num_scripts; ++i) { | 165 for (size_t i = 0; i < num_scripts; ++i) { |
| 166 scripts_.push_back(new UserScript()); | 166 scripts_.push_back(new UserScript()); |
| 167 UserScript* script = scripts_.back(); | 167 UserScript* script = scripts_.back(); |
| 168 script->Unpickle(pickle, &iter); | 168 script->Unpickle(pickle, &iter); |
| 169 | 169 |
| 170 // Note that this is a pointer into shared memory. We don't own it. It gets | 170 // Note that this is a pointer into shared memory. We don't own it. It gets |
| 171 // cleared up when the last renderer or browser process drops their | 171 // cleared up when the last renderer or browser process drops their |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 if (num_scripts) | 333 if (num_scripts) |
| 334 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); | 334 UMA_HISTOGRAM_TIMES("Extensions.InjectEnd_Time", timer.Elapsed()); |
| 335 } else if (location == UserScript::DOCUMENT_IDLE) { | 335 } else if (location == UserScript::DOCUMENT_IDLE) { |
| 336 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); | 336 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); |
| 337 if (num_scripts) | 337 if (num_scripts) |
| 338 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); | 338 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); |
| 339 } else { | 339 } else { |
| 340 NOTREACHED(); | 340 NOTREACHED(); |
| 341 } | 341 } |
| 342 } | 342 } |
| OLD | NEW |