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

Unified Diff: chrome/default_plugin/plugin_install_job_monitor.cc

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/default_plugin/plugin_install_job_monitor.h ('k') | chrome/renderer/custom_menu_commands.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/default_plugin/plugin_install_job_monitor.cc
diff --git a/chrome/default_plugin/plugin_install_job_monitor.cc b/chrome/default_plugin/plugin_install_job_monitor.cc
deleted file mode 100644
index a5625693f3afc31bc05293e58ff0fcfa87a1836a..0000000000000000000000000000000000000000
--- a/chrome/default_plugin/plugin_install_job_monitor.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/default_plugin/plugin_install_job_monitor.h"
-
-#include "base/bind.h"
-#include "base/message_loop.h"
-#include "chrome/default_plugin/plugin_impl.h"
-
-PluginInstallationJobMonitorThread::PluginInstallationJobMonitorThread()
- : Thread("Chrome plugin install thread"),
- install_job_completion_port_(NULL),
- stop_job_monitoring_(false),
- plugin_window_(NULL),
- install_job_(NULL) {
-}
-
-PluginInstallationJobMonitorThread::~PluginInstallationJobMonitorThread() {
- // The way this class is used, Thread::Stop() has always been called
- // by the time we reach this point, so we do not need to call it
- // again.
- DCHECK(!Thread::IsRunning());
- if (install_job_) {
- ::CloseHandle(install_job_);
- install_job_ = NULL;
- }
-}
-
-bool PluginInstallationJobMonitorThread::Initialize() {
- DCHECK(install_job_ == NULL);
-
- install_job_ = ::CreateJobObject(NULL, NULL);
- if (install_job_ == NULL) {
- DLOG(ERROR) << "Failed to create plugin install job. Error = "
- << ::GetLastError();
- NOTREACHED();
- return false;
- }
-
- return Start();
-}
-
-void PluginInstallationJobMonitorThread::Init() {
- this->message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&PluginInstallationJobMonitorThread::WaitForJobThread, this));
-}
-
-void PluginInstallationJobMonitorThread::WaitForJobThread() {
- if (!install_job_) {
- DLOG(WARNING) << "Invalid job information";
- NOTREACHED();
- return;
- }
-
- DCHECK(install_job_completion_port_ == NULL);
-
- install_job_completion_port_ =
- ::CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL,
- reinterpret_cast<ULONG_PTR>(install_job_), 0);
- DCHECK(install_job_completion_port_ != NULL);
-
- JOBOBJECT_ASSOCIATE_COMPLETION_PORT job_completion_port = {0};
- job_completion_port.CompletionKey = install_job_;
- job_completion_port.CompletionPort = install_job_completion_port_;
-
- if (!SetInformationJobObject(install_job_,
- JobObjectAssociateCompletionPortInformation,
- &job_completion_port,
- sizeof(job_completion_port))) {
- DLOG(WARNING) << "Failed to associate completion port with job object.Err "
- << ::GetLastError();
- NOTREACHED();
- return;
- }
-
- while (!stop_job_monitoring_) {
- unsigned long job_event = 0;
- unsigned long completion_key = 0;
- LPOVERLAPPED overlapped = NULL;
-
- if (::GetQueuedCompletionStatus(
- install_job_completion_port_, &job_event,
- &completion_key, &overlapped, INFINITE)) {
- if (job_event == JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO) {
- DVLOG(1) << "All processes in the installer job have exited. "
- "Initiating refresh on the plugins list";
- DCHECK(::IsWindow(plugin_window_));
- PostMessageW(plugin_window_,
- PluginInstallerImpl::kRefreshPluginsMessage, 0, 0);
- }
- }
- }
-}
-
-void PluginInstallationJobMonitorThread::Stop() {
- stop_job_monitoring_ = true;
- ::PostQueuedCompletionStatus(
- install_job_completion_port_, JOB_OBJECT_MSG_END_OF_JOB_TIME,
- reinterpret_cast<ULONG_PTR>(install_job_), NULL);
- Thread::Stop();
- ::CloseHandle(install_job_completion_port_);
- install_job_completion_port_ = NULL;
-}
-
-bool PluginInstallationJobMonitorThread::AssignProcessToJob(
- HANDLE process_handle) {
- BOOL result = AssignProcessToJobObject(install_job_, process_handle);
- return result ? true : false;
-}
« no previous file with comments | « chrome/default_plugin/plugin_install_job_monitor.h ('k') | chrome/renderer/custom_menu_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698