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/browser/extensions/api/processes/processes_api.h" | 5 #include "chrome/browser/extensions/api/processes/processes_api.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 // Add a reference, which is balanced in GetProcessIdForTab to keep the object | 545 // Add a reference, which is balanced in GetProcessIdForTab to keep the object |
546 // around and allow for the callback to be invoked. | 546 // around and allow for the callback to be invoked. |
547 AddRef(); | 547 AddRef(); |
548 | 548 |
549 // If the task manager is already listening, just post a task to execute | 549 // If the task manager is already listening, just post a task to execute |
550 // which will invoke the callback once we have returned from this function. | 550 // which will invoke the callback once we have returned from this function. |
551 // Otherwise, wait for the notification that the task manager is done with | 551 // Otherwise, wait for the notification that the task manager is done with |
552 // the data gathering. | 552 // the data gathering. |
553 if (ProcessesAPI::Get(profile_)->processes_event_router()-> | 553 if (ProcessesAPI::Get(profile_)->processes_event_router()-> |
554 is_task_manager_listening()) { | 554 is_task_manager_listening()) { |
555 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 555 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
556 &GetProcessIdForTabFunction::GetProcessIdForTab, this)); | 556 &GetProcessIdForTabFunction::GetProcessIdForTab, this)); |
557 } else { | 557 } else { |
558 registrar_.Add(this, | 558 registrar_.Add(this, |
559 chrome::NOTIFICATION_TASK_MANAGER_CHILD_PROCESSES_DATA_READY, | 559 chrome::NOTIFICATION_TASK_MANAGER_CHILD_PROCESSES_DATA_READY, |
560 content::NotificationService::AllSources()); | 560 content::NotificationService::AllSources()); |
561 ProcessesAPI::Get(profile_)->processes_event_router()-> | 561 ProcessesAPI::Get(profile_)->processes_event_router()-> |
562 StartTaskManagerListening(); | 562 StartTaskManagerListening(); |
563 } | 563 } |
564 | 564 |
565 return true; | 565 return true; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 // Add a reference, which is balanced in TerminateProcess to keep the object | 608 // Add a reference, which is balanced in TerminateProcess to keep the object |
609 // around and allow for the callback to be invoked. | 609 // around and allow for the callback to be invoked. |
610 AddRef(); | 610 AddRef(); |
611 | 611 |
612 // If the task manager is already listening, just post a task to execute | 612 // If the task manager is already listening, just post a task to execute |
613 // which will invoke the callback once we have returned from this function. | 613 // which will invoke the callback once we have returned from this function. |
614 // Otherwise, wait for the notification that the task manager is done with | 614 // Otherwise, wait for the notification that the task manager is done with |
615 // the data gathering. | 615 // the data gathering. |
616 if (ProcessesAPI::Get(profile_)->processes_event_router()-> | 616 if (ProcessesAPI::Get(profile_)->processes_event_router()-> |
617 is_task_manager_listening()) { | 617 is_task_manager_listening()) { |
618 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 618 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
619 &TerminateFunction::TerminateProcess, this)); | 619 &TerminateFunction::TerminateProcess, this)); |
620 } else { | 620 } else { |
621 registrar_.Add(this, | 621 registrar_.Add(this, |
622 chrome::NOTIFICATION_TASK_MANAGER_CHILD_PROCESSES_DATA_READY, | 622 chrome::NOTIFICATION_TASK_MANAGER_CHILD_PROCESSES_DATA_READY, |
623 content::NotificationService::AllSources()); | 623 content::NotificationService::AllSources()); |
624 ProcessesAPI::Get(profile_)->processes_event_router()-> | 624 ProcessesAPI::Get(profile_)->processes_event_router()-> |
625 StartTaskManagerListening(); | 625 StartTaskManagerListening(); |
626 } | 626 } |
627 | 627 |
628 return true; | 628 return true; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 // Add a reference, which is balanced in GatherProcessInfo to keep the object | 696 // Add a reference, which is balanced in GatherProcessInfo to keep the object |
697 // around and allow for the callback to be invoked. | 697 // around and allow for the callback to be invoked. |
698 AddRef(); | 698 AddRef(); |
699 | 699 |
700 // If the task manager is already listening, just post a task to execute | 700 // If the task manager is already listening, just post a task to execute |
701 // which will invoke the callback once we have returned from this function. | 701 // which will invoke the callback once we have returned from this function. |
702 // Otherwise, wait for the notification that the task manager is done with | 702 // Otherwise, wait for the notification that the task manager is done with |
703 // the data gathering. | 703 // the data gathering. |
704 if (ProcessesAPI::Get(profile_)->processes_event_router()-> | 704 if (ProcessesAPI::Get(profile_)->processes_event_router()-> |
705 is_task_manager_listening()) { | 705 is_task_manager_listening()) { |
706 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 706 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
707 &GetProcessInfoFunction::GatherProcessInfo, this)); | 707 &GetProcessInfoFunction::GatherProcessInfo, this)); |
708 } else { | 708 } else { |
709 registrar_.Add(this, | 709 registrar_.Add(this, |
710 chrome::NOTIFICATION_TASK_MANAGER_CHILD_PROCESSES_DATA_READY, | 710 chrome::NOTIFICATION_TASK_MANAGER_CHILD_PROCESSES_DATA_READY, |
711 content::NotificationService::AllSources()); | 711 content::NotificationService::AllSources()); |
712 ProcessesAPI::Get(profile_)->processes_event_router()-> | 712 ProcessesAPI::Get(profile_)->processes_event_router()-> |
713 StartTaskManagerListening(); | 713 StartTaskManagerListening(); |
714 } | 714 } |
715 return true; | 715 return true; |
716 | 716 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 771 |
772 SetResult(processes); | 772 SetResult(processes); |
773 SendResponse(true); | 773 SendResponse(true); |
774 | 774 |
775 // Balance the AddRef in the RunImpl. | 775 // Balance the AddRef in the RunImpl. |
776 Release(); | 776 Release(); |
777 #endif // defined(ENABLE_TASK_MANAGER) | 777 #endif // defined(ENABLE_TASK_MANAGER) |
778 } | 778 } |
779 | 779 |
780 } // namespace extensions | 780 } // namespace extensions |
OLD | NEW |