diff options
author | maksymb@chromium.org <maksymb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 20:20:32 +0000 |
---|---|---|
committer | maksymb@chromium.org <maksymb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 20:20:32 +0000 |
commit | d39367940a7128698a78b94d59680176f7700160 (patch) | |
tree | d7025ee1646b806f56f2d218599013aa57dae510 /cloud_print/gcp20 | |
parent | e996309dfa0c63357ce381d7740301ab8b1c3cec (diff) | |
download | chromium_src-d39367940a7128698a78b94d59680176f7700160.zip chromium_src-d39367940a7128698a78b94d59680176f7700160.tar.gz chromium_src-d39367940a7128698a78b94d59680176f7700160.tar.bz2 |
GCP2.0 Device: Fixed XMPP crash while closing.
BUG=
Review URL: https://chromiumcodereview.appspot.com/22331004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print/gcp20')
-rw-r--r-- | cloud_print/gcp20/prototype/gcp20_device.cc | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/cloud_print/gcp20/prototype/gcp20_device.cc b/cloud_print/gcp20/prototype/gcp20_device.cc index 01d34ed..9e67ca7 100644 --- a/cloud_print/gcp20/prototype/gcp20_device.cc +++ b/cloud_print/gcp20/prototype/gcp20_device.cc @@ -49,17 +49,24 @@ void StartPrinter(Printer* printer) { base::RunLoop* g_runner = NULL; Printer* g_printer = NULL; +base::MessageLoop* g_message_loop; + +void StopLoop() { + // Always do after printer.Stop() to make sure XMPP will + // be disabled fully before |Quit| will be called + // (XMPP disables itself via MessageLoop call). + g_message_loop->PostTask(FROM_HERE, g_runner->QuitClosure()); + g_message_loop = NULL; + g_runner = NULL; +} void OnAbort(int val) { - if (g_runner) { - g_printer->Stop(); // TODO(maksymb): Make this call in safe place call: - // |OnAbort| is called from different thread. + if (g_printer) { + g_message_loop->PostTask( + FROM_HERE, + base::Bind(&Printer::Stop, base::Unretained(g_printer))); + g_message_loop->PostTask(FROM_HERE, base::Bind(&StopLoop)); g_printer = NULL; - - g_runner->Quit(); // Always do after printer.Stop() to make sure XMPP will - // be disabled fully before |Quit| will be called - // (XMPP disables itself via MessageLoop call). - g_runner = NULL; } } @@ -83,8 +90,8 @@ int main(int argc, char* argv[]) { signal(SIGINT, OnAbort); // Handle Ctrl+C signal. base::MessageLoop loop(base::MessageLoop::TYPE_IO); - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&StartPrinter, &printer)); + g_message_loop = &loop; + g_message_loop->PostTask(FROM_HERE, base::Bind(&StartPrinter, &printer)); base::RunLoop runner; g_printer = &printer; g_runner = &runner; |