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

Unified Diff: ui/viewer/viewer_process.cc

Issue 10872002: beginnings of metro viewer process (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 8 years, 3 months 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 | « ui/viewer/viewer_process.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/viewer/viewer_process.cc
diff --git a/ui/viewer/viewer_process.cc b/ui/viewer/viewer_process.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9440aeb5a1c56f7f8f61c86d66ae29f4dd0096f3
--- /dev/null
+++ b/ui/viewer/viewer_process.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 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 "ui/viewer/viewer_process.h"
+
+#include "ui/viewer/viewer_ipc_server.h"
+#include "ui/viewer/viewer_host_win.h"
+
+ViewerProcess* g_viewer_process = NULL;
+
+ViewerProcess::ViewerProcess()
+ : shutdown_event_(true, false),
+ main_message_loop_(NULL) {
+ DCHECK(!g_viewer_process);
+ g_viewer_process = this;
+}
+
+ViewerProcess::~ViewerProcess() {
+ Teardown();
+ g_viewer_process = NULL;
+}
+
+bool ViewerProcess::Initialize(MessageLoop* message_loop,
+ const CommandLine& command_line) {
+ main_message_loop_ = message_loop;
+
+ base::Thread::Options options;
+ options.message_loop_type = MessageLoop::TYPE_IO;
+ io_thread_.reset(new base::Thread("ViewerProcess_IO"));
+ if (!io_thread_->StartWithOptions(options)) {
+ NOTREACHED();
+ Teardown();
+ return false;
+ }
+
+ VLOG(1) << "Starting Viewer Process IPC Server";
+ // TODO(scottmg): Channel name should be per user-data-dir.
+ ipc_server_.reset(new ViewerIPCServer("viewer_ipc"));
+ ipc_server_->Init();
+
+ // TODO(scottmg): I guess the whole thing should be made Windows-only at
+ // some point.
+#if defined(OS_WIN)
+ viewer_host_win_.reset(new ViewerHostWin);
+#endif
+
+ // TODO(scottmg): Ask for a handle here, maybe start a browser, all that
+ // jazz.
+
+ return true;
+}
+
+bool ViewerProcess::Teardown() {
+ ipc_server_.reset();
+ io_thread_.reset();
+ return true;
+}
+
+bool ViewerProcess::HandleClientDisconnect() {
+ Terminate();
+ return false;
+}
+
+void ViewerProcess::Terminate() {
+ main_message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
+}
« no previous file with comments | « ui/viewer/viewer_process.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698