summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-23 18:03:29 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-23 18:03:29 +0000
commit569b1106f62d531c11f857f08961f41efe2b272e (patch)
treec9a4d93a65b16317604e544854f5ee9a15751896
parent423bd5b84aee7a02b62e4e4d8a83d7df6c0943d9 (diff)
downloadchromium_src-569b1106f62d531c11f857f08961f41efe2b272e.zip
chromium_src-569b1106f62d531c11f857f08961f41efe2b272e.tar.gz
chromium_src-569b1106f62d531c11f857f08961f41efe2b272e.tar.bz2
Porting in chrome/
Review URL: http://codereview.chromium.org/18446 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8560 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/process_util.h3
-rw-r--r--base/process_util_posix.cc4
-rw-r--r--base/process_util_win.cc6
-rw-r--r--chrome/browser/base_history_model.cc4
-rw-r--r--chrome/browser/bookmarks/bookmark_utils.h4
-rw-r--r--chrome/browser/browser.scons4
-rw-r--r--chrome/common/common.scons7
-rw-r--r--chrome/common/process_watcher.cc78
-rw-r--r--chrome/common/security_filter_peer.h2
-rw-r--r--chrome/views/table_view.h10
-rw-r--r--chrome/views/tree_node_model.h4
11 files changed, 70 insertions, 56 deletions
diff --git a/base/process_util.h b/base/process_util.h
index f00016e..4cadafc 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -61,6 +61,9 @@ int GetCurrentProcId();
// Returns the ProcessHandle of the current process.
ProcessHandle GetCurrentProcessHandle();
+// Closes given process handle. Returns true on success.
+bool CloseProcessHandle(ProcessHandle process);
+
// Returns the unique ID for the specified process. This is functionally the
// same as Windows' GetProcessId(), but works on versions of Windows before
// Win XP SP1 as well.
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 87a4e36..9dbb2e6 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -30,6 +30,10 @@ ProcessHandle GetCurrentProcessHandle() {
return GetCurrentProcId();
}
+bool CloseProcessHandle(ProcessHandle process) {
+ return true;
+}
+
int GetProcId(ProcessHandle process) {
return process;
}
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index f1fd72c..e725e56 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -33,6 +33,10 @@ ProcessHandle GetCurrentProcessHandle() {
return ::GetCurrentProcess();
}
+bool CloseProcessHandle(ProcessHandle process) {
+ return ::CloseHandle(process) ? true : false;
+}
+
// Helper for GetProcId()
bool GetProcIdViaGetProcessId(ProcessHandle process, DWORD* id) {
// Dynamically get a pointer to GetProcessId().
@@ -188,7 +192,7 @@ bool DidProcessCrash(ProcessHandle handle) {
// Warning, this is not generic code; it heavily depends on the way
// the rest of the code kills a process.
-
+
if (exitcode == PROCESS_END_NORMAL_TERMINATON ||
exitcode == PROCESS_END_KILLED_BY_USER ||
exitcode == PROCESS_END_PROCESS_WAS_HUNG ||
diff --git a/chrome/browser/base_history_model.cc b/chrome/browser/base_history_model.cc
index eda43c0..cce4923 100644
--- a/chrome/browser/base_history_model.cc
+++ b/chrome/browser/base_history_model.cc
@@ -23,9 +23,9 @@ const int BaseHistoryModel::kHistoryScopeMonths = 18;
BaseHistoryModel::BaseHistoryModel(Profile* profile)
: profile_(profile),
observer_(NULL),
+ is_search_results_(false),
thumbnails_(kThumbnailCacheSize),
- favicons_(kThumbnailCacheSize),
- is_search_results_(false) {
+ favicons_(kThumbnailCacheSize) {
if (!kDefaultFavicon) {
kDefaultFavicon = ResourceBundle::GetSharedInstance().
GetBitmapNamed(IDR_DEFAULT_FAVICON);
diff --git a/chrome/browser/bookmarks/bookmark_utils.h b/chrome/browser/bookmarks/bookmark_utils.h
index 7a83caa..b41542b 100644
--- a/chrome/browser/bookmarks/bookmark_utils.h
+++ b/chrome/browser/bookmarks/bookmark_utils.h
@@ -42,6 +42,9 @@ void CloneDragData(BookmarkModel* model,
BookmarkNode* parent,
int index_to_add_at);
+#if defined(OS_WIN)
+// TODO(port): Make OpenAll portable (remove HWND).
+
// Recursively opens all bookmarks. |initial_disposition| dictates how the
// first URL is opened, all subsequent URLs are opened as background tabs.
// |navigator| is used to open the URLs. If |navigator| is NULL the last
@@ -59,6 +62,7 @@ void OpenAll(HWND parent,
PageNavigator* navigator,
BookmarkNode* node,
WindowOpenDisposition initial_disposition);
+#endif // defined(OS_WIN)
// Copies nodes onto the clipboard. If |remove_nodes| is true the nodes are
// removed after copied to the clipboard. The nodes are copied in such a way
diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons
index 2a94ddd..c200bb3 100644
--- a/chrome/browser/browser.scons
+++ b/chrome/browser/browser.scons
@@ -675,21 +675,17 @@ if not env.Bit('windows'):
'autocomplete/autocomplete_edit.cc',
'autocomplete/autocomplete_popup.cc',
'autocomplete/edit_drop_target.cc',
- 'autocomplete/history_contents_provider.cc',
'autocomplete/history_url_provider.cc',
'autocomplete/search_provider.cc',
'automation/automation_provider.cc',
'automation/automation_provider_list.cc',
'automation/ui_controls.cc',
'back_forward_menu_model.cc',
- 'base_history_model.cc',
'bookmarks/bookmark_context_menu.cc',
'bookmarks/bookmark_drag_data.cc',
'bookmarks/bookmark_drop_info.cc',
- 'bookmarks/bookmark_folder_tree_model.cc',
'bookmarks/bookmark_model.cc',
'bookmarks/bookmark_storage.cc',
- 'bookmarks/bookmark_table_model.cc',
'bookmarks/bookmark_utils.cc',
'browser.cc',
'browser_about_handler.cc',
diff --git a/chrome/common/common.scons b/chrome/common/common.scons
index 7f2fd74..8761002 100644
--- a/chrome/common/common.scons
+++ b/chrome/common/common.scons
@@ -218,13 +218,8 @@ if not env.Bit('windows'):
'gfx/icon_util.cc',
'gfx/path.cc',
'ipc_logging.cc',
- 'jstemplate_builder.cc',
'os_exchange_data.cc',
'plugin_messages.cc',
- 'process_watcher.cc',
- 'security_filter_peer.cc',
- 'win_safe_util.cc',
- 'win_util.cc',
)
if not env.Bit('windows'):
@@ -235,6 +230,8 @@ if not env.Bit('windows'):
'gfx/chrome_font_win.cc',
'ipc_channel_win.cc',
'resource_bundle_win.cc',
+ 'win_safe_util.cc',
+ 'win_util.cc',
'$CHROME_DIR/tools/build/win/precompiled$OBJSUFFIX',
)
diff --git a/chrome/common/process_watcher.cc b/chrome/common/process_watcher.cc
index b43e2db..ceabaea2 100644
--- a/chrome/common/process_watcher.cc
+++ b/chrome/common/process_watcher.cc
@@ -4,9 +4,13 @@
#include "chrome/common/process_watcher.h"
+#include "base/basictypes.h"
#include "base/message_loop.h"
-#include "base/object_watcher.h"
+#include "base/process.h"
+#include "base/process_util.h"
#include "base/sys_info.h"
+#include "base/timer.h"
+#include "base/worker_pool.h"
#include "chrome/app/result_codes.h"
#include "chrome/common/env_vars.h"
@@ -15,80 +19,72 @@ static const int kWaitInterval = 2000;
namespace {
-class TimerExpiredTask : public Task, public base::ObjectWatcher::Delegate {
+class TerminatorTask : public Task {
public:
- explicit TimerExpiredTask(base::ProcessHandle process) : process_(process) {
- watcher_.StartWatching(process_, this);
+ explicit TerminatorTask(base::ProcessHandle process) : process_(process) {
+ timer_.Start(base::TimeDelta::FromMilliseconds(kWaitInterval),
+ this, &TerminatorTask::KillProcess);
}
- virtual ~TimerExpiredTask() {
+ virtual ~TerminatorTask() {
if (process_) {
KillProcess();
- DCHECK(!process_) << "Make sure to close the handle.";
+ DCHECK(!process_);
}
}
- // Task ---------------------------------------------------------------------
-
virtual void Run() {
+ base::WaitForSingleProcess(process_, kWaitInterval);
+ timer_.Stop();
if (process_)
KillProcess();
}
- // MessageLoop::Watcher -----------------------------------------------------
-
- virtual void OnObjectSignaled(HANDLE object) {
- // When we're called from KillProcess, the ObjectWatcher may still be
- // watching. the process handle, so make sure it has stopped.
- watcher_.StopWatching();
-
- CloseHandle(process_);
- process_ = NULL;
- }
-
private:
void KillProcess() {
if (base::SysInfo::HasEnvVar(env_vars::kHeadless)) {
- // If running the distributed tests, give the renderer a little time
- // to figure out that the channel is shutdown and unwind.
- if (WaitForSingleObject(process_, kWaitInterval) == WAIT_OBJECT_0) {
- OnObjectSignaled(process_);
- return;
- }
+ // If running the distributed tests, give the renderer a little time
+ // to figure out that the channel is shutdown and unwind.
+ if (base::WaitForSingleProcess(process_, kWaitInterval)) {
+ Cleanup();
+ return;
+ }
}
// OK, time to get frisky. We don't actually care when the process
- // terminates. We just care that it eventually terminates, and that's what
- // TerminateProcess should do for us. Don't check for the result code since
- // it fails quite often. This should be investigated eventually.
- TerminateProcess(process_, ResultCodes::HUNG);
+ // terminates. We just care that it eventually terminates.
+ base::KillProcess(base::Process(process_).pid(),
+ ResultCodes::HUNG,
+ false /* don't wait */);
- // Now, just cleanup as if the process exited normally.
- OnObjectSignaled(process_);
+ Cleanup();
+ }
+
+ void Cleanup() {
+ timer_.Stop();
+ base::CloseProcessHandle(process_);
+ process_ = NULL;
}
// The process that we are watching.
base::ProcessHandle process_;
- base::ObjectWatcher watcher_;
+ base::OneShotTimer<TerminatorTask> timer_;
- DISALLOW_EVIL_CONSTRUCTORS(TimerExpiredTask);
+ DISALLOW_COPY_AND_ASSIGN(TerminatorTask);
};
} // namespace
// static
void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process) {
- DCHECK(process != GetCurrentProcess());
+ DCHECK(base::GetProcId(process) != base::GetCurrentProcId());
- // If already signaled, then we are done!
- if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) {
- CloseHandle(process);
+ // Check if the process has already exited.
+ if (base::WaitForSingleProcess(process, 0)) {
+ base::CloseProcessHandle(process);
return;
}
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- new TimerExpiredTask(process),
- kWaitInterval);
+ WorkerPool::PostTask(FROM_HERE, new TerminatorTask(process), true);
}
-
diff --git a/chrome/common/security_filter_peer.h b/chrome/common/security_filter_peer.h
index 616680d..ef19b71 100644
--- a/chrome/common/security_filter_peer.h
+++ b/chrome/common/security_filter_peer.h
@@ -50,8 +50,8 @@ class SecurityFilterPeer : public webkit_glue::ResourceLoaderBridge::Peer {
SecurityFilterPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
webkit_glue::ResourceLoaderBridge::Peer* peer);
- webkit_glue::ResourceLoaderBridge* resource_loader_bridge_;
webkit_glue::ResourceLoaderBridge::Peer* original_peer_;
+ webkit_glue::ResourceLoaderBridge* resource_loader_bridge_;
private:
DISALLOW_EVIL_CONSTRUCTORS(SecurityFilterPeer);
diff --git a/chrome/views/table_view.h b/chrome/views/table_view.h
index 88dada3..abe0f45 100644
--- a/chrome/views/table_view.h
+++ b/chrome/views/table_view.h
@@ -5,7 +5,11 @@
#ifndef CHROME_VIEWS_TABLE_VIEW_H_
#define CHROME_VIEWS_TABLE_VIEW_H_
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
#include <windows.h>
+#endif // defined(OS_WIN)
#include <map>
#include <unicode/coll.h>
@@ -14,7 +18,10 @@
#include "base/logging.h"
#include "chrome/common/l10n_util.h"
+#if defined(OS_WIN)
+// TODO(port): remove the ifdef when native_control.h is ported.
#include "chrome/views/native_control.h"
+#endif // defined(OS_WIN)
#include "SkColor.h"
class SkBitmap;
@@ -284,6 +291,8 @@ class TableViewObserver {
virtual void OnTableViewDelete(TableView* table_view) {}
};
+#if defined(OS_WIN)
+// TODO(port): Port TableView.
class TableView : public NativeControl,
public TableModelObserver {
public:
@@ -661,6 +670,7 @@ class TableView : public NativeControl,
DISALLOW_COPY_AND_ASSIGN(TableView);
};
+#endif // defined(OS_WIN)
} // namespace views
diff --git a/chrome/views/tree_node_model.h b/chrome/views/tree_node_model.h
index 695e4ab..18b93f9 100644
--- a/chrome/views/tree_node_model.h
+++ b/chrome/views/tree_node_model.h
@@ -189,8 +189,8 @@ class TreeNodeModel : public TreeModel {
// Creates a TreeNodeModel with the specified root node. The root is owned
// by the TreeNodeModel.
explicit TreeNodeModel(NodeType* root)
- : observer_(NULL),
- root_(root) {
+ : root_(root),
+ observer_(NULL) {
}
virtual ~TreeNodeModel() {}