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

Unified Diff: base/message_pump_glib.cc

Issue 6489031: Run event executor on the ui thread to remove the need to explicitly XFlush() the XTest calls. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: git cl try Created 9 years, 10 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 | « no previous file | chrome/service/remoting/chromoting_host_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_glib.cc
diff --git a/base/message_pump_glib.cc b/base/message_pump_glib.cc
index 721fedb6a63ab219043395b27353386daaa5c4bb..f12bb8abb622356180221b8b64033ad671462b5a 100644
--- a/base/message_pump_glib.cc
+++ b/base/message_pump_glib.cc
@@ -10,12 +10,41 @@
#include <gtk/gtk.h>
#include <glib.h>
+#include <string>
+#include <vector>
+
#include "base/eintr_wrapper.h"
#include "base/logging.h"
+#include "base/command_line.h"
#include "base/threading/platform_thread.h"
namespace {
+// TODO(jamiewalch): This is pretty much a direct copy of
+// gfx::GtkInitFromCommandLine. The fact that it calls gdk_init instead of
+// gtk_init is probably unimportant as the latter calls the former, but
+// we can't have base depending on ui so we can't use the function directly.
+void GdkInitFromCommandLine(const CommandLine& command_line) {
+ const std::vector<std::string>& args = command_line.argv();
+ int argc = args.size();
+ scoped_array<char *> argv(new char *[argc + 1]);
+ for (size_t i = 0; i < args.size(); ++i) {
+ // gdk_init makes no const-ness guarantees so best to be safe here. If it
+ // doesn't delete the arguments it consumes, then there is a small memory
+ // leak, but the alternative is far more severe.
+ argv[i] = strdup(args[i].c_str());
+ }
+ argv[argc] = NULL;
+ char **argv_pointer = argv.get();
+
+ gdk_init(&argc, &argv_pointer);
+ // gfx::GtkInitFromCommandLine uses args.size() instead of argc for the loop
+ // limit, which I believe is wrong, though probably benign.
+ for (int i = 0; i < argc; ++i) {
+ free(argv[i]);
+ }
+}
+
// We send a byte across a pipe to wakeup the event loop.
const char kWorkScheduled = '\0';
@@ -144,6 +173,9 @@ MessagePumpForUI::MessagePumpForUI()
: state_(NULL),
context_(g_main_context_default()),
wakeup_gpollfd_(new GPollFD) {
+ // Initialize gdk.
Dean McNamee 2011/02/15 17:06:26 This is the classic style of comment: // Add one
Jamie 2011/02/15 17:17:03 Yes, I put the comment in before I factored out th
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ GdkInitFromCommandLine(*command_line);
// Create our wakeup pipe, which is used to flag when work was scheduled.
int fds[2];
CHECK_EQ(pipe(fds), 0);
« no previous file with comments | « no previous file | chrome/service/remoting/chromoting_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698