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

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

Issue 10804020: Introduce runtime.onSuspendCanceled() event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos call Created 8 years, 5 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 | Annotate | Revision Log
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/extension_message_service.h" 5 #include "chrome/browser/extensions/extension_message_service.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 425 }
426 } 426 }
427 427
428 bool ExtensionMessageService::MaybeAddPendingOpenChannelTask( 428 bool ExtensionMessageService::MaybeAddPendingOpenChannelTask(
429 Profile* profile, 429 Profile* profile,
430 const OpenChannelParams& params) { 430 const OpenChannelParams& params) {
431 ExtensionService* service = profile->GetExtensionService(); 431 ExtensionService* service = profile->GetExtensionService();
432 const std::string& extension_id = params.target_extension_id; 432 const std::string& extension_id = params.target_extension_id;
433 const extensions::Extension* extension = service->extensions()->GetByID( 433 const extensions::Extension* extension = service->extensions()->GetByID(
434 extension_id); 434 extension_id);
435 if (extension && extension->has_lazy_background_page()) { 435 if (extension) {
436 // If the extension uses spanning incognito mode, make sure we're always 436 // If the extension uses spanning incognito mode, make sure we're always
437 // using the original profile since that is what the extension process 437 // using the original profile since that is what the extension process
438 // will use. 438 // will use.
439 if (!extension->incognito_split_mode()) 439 if (!extension->incognito_split_mode())
440 profile = profile->GetOriginalProfile(); 440 profile = profile->GetOriginalProfile();
441 441
442 if (lazy_background_task_queue_->ShouldEnqueueTask(profile, extension)) { 442 lazy_background_task_queue_->AddPendingTask(profile, extension_id,
443 lazy_background_task_queue_->AddPendingTask(profile, extension_id, 443 base::Bind(&ExtensionMessageService::PendingOpenChannel,
444 base::Bind(&ExtensionMessageService::PendingOpenChannel, 444 base::Unretained(this), params, params.source->GetID()));
445 base::Unretained(this), params, params.source->GetID())); 445 pending_channels_[GET_CHANNEL_ID(params.receiver_port_id)] =
446 pending_channels_[GET_CHANNEL_ID(params.receiver_port_id)] = 446 PendingChannel(profile, extension_id);
447 PendingChannel(profile, extension_id); 447 return true;
448 return true;
449 }
450 } 448 }
451 449
452 return false; 450 return false;
453 } 451 }
454 452
455 void ExtensionMessageService::PendingOpenChannel( 453 void ExtensionMessageService::PendingOpenChannel(
456 const OpenChannelParams& params_in, 454 const OpenChannelParams& params_in,
457 int source_process_id, 455 int source_process_id,
458 ExtensionHost* host) { 456 ExtensionHost* host) {
459 if (!host) 457 if (!host)
460 return; // TODO(mpcomplete): notify source of disconnect? 458 return; // TODO(mpcomplete): notify source of disconnect?
461 459
462 // Re-lookup the source process since it may no longer be valid. 460 // Re-lookup the source process since it may no longer be valid.
463 OpenChannelParams params = params_in; 461 OpenChannelParams params = params_in;
464 params.source = content::RenderProcessHost::FromID(source_process_id); 462 params.source = content::RenderProcessHost::FromID(source_process_id);
465 if (!params.source) 463 if (!params.source)
466 return; 464 return;
467 465
468 params.receiver = MessagePort(host->render_process_host(), 466 params.receiver = MessagePort(host->render_process_host(),
469 MSG_ROUTING_CONTROL, 467 MSG_ROUTING_CONTROL,
470 params.target_extension_id); 468 params.target_extension_id);
471 OpenChannelImpl(params); 469 OpenChannelImpl(params);
472 } 470 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698