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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
633 | 633 |
634 return true; | 634 return true; |
635 #else | 635 #else |
636 error_ = errors::kExtensionNotSupported; | 636 error_ = errors::kExtensionNotSupported; |
637 return false; | 637 return false; |
638 #endif // defined(ENABLE_TASK_MANAGER) | 638 #endif // defined(ENABLE_TASK_MANAGER) |
639 } | 639 } |
640 | 640 |
641 | 641 |
642 void TerminateFunction::TerminateProcess() { | 642 void TerminateFunction::TerminateProcess() { |
643 #if defined(ENABLE_TASK_MANAGER) | |
643 TaskManagerModel* model = TaskManager::GetInstance()->model(); | 644 TaskManagerModel* model = TaskManager::GetInstance()->model(); |
644 | 645 |
645 int count = model->ResourceCount(); | 646 int count = model->ResourceCount(); |
646 bool killed = false; | 647 bool killed = false; |
647 bool found = false; | 648 bool found = false; |
648 | 649 |
649 for (int i = 0; i < count; ++i) { | 650 for (int i = 0; i < count; ++i) { |
650 if (model->IsResourceFirstInGroup(i)) { | 651 if (model->IsResourceFirstInGroup(i)) { |
651 if (process_id_ == model->GetUniqueChildProcessId(i)) { | 652 if (process_id_ == model->GetUniqueChildProcessId(i)) { |
652 found = true; | 653 found = true; |
653 killed = base::KillProcess(model->GetProcess(i), | 654 killed = base::KillProcess(model->GetProcess(i), |
654 content::RESULT_CODE_KILLED, true); | 655 content::RESULT_CODE_KILLED, true); |
655 UMA_HISTOGRAM_COUNTS("ChildProcess.KilledByExtensionAPI", 1); | 656 UMA_HISTOGRAM_COUNTS("ChildProcess.KilledByExtensionAPI", 1); |
656 break; | 657 break; |
657 } | 658 } |
658 } | 659 } |
659 } | 660 } |
660 | 661 |
661 if (!found) { | 662 if (!found) { |
662 error_ = ErrorUtils::FormatErrorMessage(errors::kProcessNotFound, | 663 error_ = ErrorUtils::FormatErrorMessage(errors::kProcessNotFound, |
663 base::IntToString(process_id_)); | 664 base::IntToString(process_id_)); |
664 SendResponse(false); | 665 SendResponse(false); |
665 } else { | 666 } else { |
666 SetResult(new base::FundamentalValue(killed)); | 667 SetResult(new base::FundamentalValue(killed)); |
667 SendResponse(true); | 668 SendResponse(true); |
668 } | 669 } |
669 | 670 |
670 // Balance the AddRef in the RunImpl. | 671 // Balance the AddRef in the RunImpl. |
671 Release(); | 672 Release(); |
673 #else | |
674 error_ = errors::kExtensionNotSupported; | |
675 #endif // defined(ENABLE_TASK_MANAGER) | |
miket_OOO
2014/03/24 23:23:26
Should there be a SendResponse() here as well?
| |
672 } | 676 } |
673 | 677 |
674 GetProcessInfoFunction::GetProcessInfoFunction() | 678 GetProcessInfoFunction::GetProcessInfoFunction() |
675 #if defined(ENABLE_TASK_MANAGER) | 679 #if defined(ENABLE_TASK_MANAGER) |
676 : memory_(false) | 680 : memory_(false) |
677 #endif | 681 #endif |
678 { | 682 { |
679 } | 683 } |
680 | 684 |
681 GetProcessInfoFunction::~GetProcessInfoFunction() { | 685 GetProcessInfoFunction::~GetProcessInfoFunction() { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
763 | 767 |
764 SetResult(processes); | 768 SetResult(processes); |
765 SendResponse(true); | 769 SendResponse(true); |
766 | 770 |
767 // Balance the AddRef in the RunImpl. | 771 // Balance the AddRef in the RunImpl. |
768 Release(); | 772 Release(); |
769 #endif // defined(ENABLE_TASK_MANAGER) | 773 #endif // defined(ENABLE_TASK_MANAGER) |
770 } | 774 } |
771 | 775 |
772 } // namespace extensions | 776 } // namespace extensions |
OLD | NEW |