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