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

Side by Side Diff: chrome/browser/extensions/user_script_master.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
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 #include "chrome/browser/extensions/user_script_master.h" 5 #include "chrome/browser/extensions/user_script_master.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 content::Source<Profile>(profile_)); 304 content::Source<Profile>(profile_));
305 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 305 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
306 content::Source<Profile>(profile_)); 306 content::Source<Profile>(profile_));
307 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 307 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
308 content::Source<Profile>(profile_)); 308 content::Source<Profile>(profile_));
309 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, 309 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED,
310 content::NotificationService::AllBrowserContextsAndSources()); 310 content::NotificationService::AllBrowserContextsAndSources());
311 } 311 }
312 312
313 UserScriptMaster::~UserScriptMaster() { 313 UserScriptMaster::~UserScriptMaster() {
314 if (script_reloader_) 314 if (script_reloader_.get())
315 script_reloader_->DisownMaster(); 315 script_reloader_->DisownMaster();
316 } 316 }
317 317
318 void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) { 318 void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) {
319 // Ensure handle is deleted or released. 319 // Ensure handle is deleted or released.
320 scoped_ptr<base::SharedMemory> handle_deleter(handle); 320 scoped_ptr<base::SharedMemory> handle_deleter(handle);
321 321
322 if (pending_load_) { 322 if (pending_load_) {
323 // While we were loading, there were further changes. Don't bother 323 // While we were loading, there were further changes. Don't bother
324 // notifying about these scripts and instead just immediately reload. 324 // notifying about these scripts and instead just immediately reload.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 return; 399 return;
400 if (ScriptsReady()) 400 if (ScriptsReady())
401 SendUpdate(process, GetSharedMemory()); 401 SendUpdate(process, GetSharedMemory());
402 break; 402 break;
403 } 403 }
404 default: 404 default:
405 DCHECK(false); 405 DCHECK(false);
406 } 406 }
407 407
408 if (should_start_load) { 408 if (should_start_load) {
409 if (script_reloader_) { 409 if (script_reloader_.get()) {
410 pending_load_ = true; 410 pending_load_ = true;
411 } else { 411 } else {
412 StartLoad(); 412 StartLoad();
413 } 413 }
414 } 414 }
415 } 415 }
416 416
417 void UserScriptMaster::StartLoad() { 417 void UserScriptMaster::StartLoad() {
418 if (!script_reloader_) 418 if (!script_reloader_.get())
419 script_reloader_ = new ScriptReloader(this); 419 script_reloader_ = new ScriptReloader(this);
420 420
421 script_reloader_->StartLoad(user_scripts_, extensions_info_); 421 script_reloader_->StartLoad(user_scripts_, extensions_info_);
422 } 422 }
423 423
424 void UserScriptMaster::SendUpdate(content::RenderProcessHost* process, 424 void UserScriptMaster::SendUpdate(content::RenderProcessHost* process,
425 base::SharedMemory* shared_memory) { 425 base::SharedMemory* shared_memory) {
426 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 426 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
427 // Make sure we only send user scripts to processes in our profile. 427 // Make sure we only send user scripts to processes in our profile.
428 if (!profile_->IsSameProfile(profile)) 428 if (!profile_->IsSameProfile(profile))
429 return; 429 return;
430 430
431 // If the process is being started asynchronously, early return. We'll end up 431 // If the process is being started asynchronously, early return. We'll end up
432 // calling InitUserScripts when it's created which will call this again. 432 // calling InitUserScripts when it's created which will call this again.
433 base::ProcessHandle handle = process->GetHandle(); 433 base::ProcessHandle handle = process->GetHandle();
434 if (!handle) 434 if (!handle)
435 return; 435 return;
436 436
437 base::SharedMemoryHandle handle_for_process; 437 base::SharedMemoryHandle handle_for_process;
438 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) 438 if (!shared_memory->ShareToProcess(handle, &handle_for_process))
439 return; // This can legitimately fail if the renderer asserts at startup. 439 return; // This can legitimately fail if the renderer asserts at startup.
440 440
441 if (base::SharedMemory::IsHandleValid(handle_for_process)) 441 if (base::SharedMemory::IsHandleValid(handle_for_process))
442 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); 442 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process));
443 } 443 }
444 444
445 } // namespace extensions 445 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/user_script_listener.cc ('k') | chrome/browser/extensions/webstore_standalone_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698