summaryrefslogtreecommitdiffstats
path: root/cloud_print
diff options
context:
space:
mode:
authormaksymb@chromium.org <maksymb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-08 20:20:32 +0000
committermaksymb@chromium.org <maksymb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-08 20:20:32 +0000
commitd39367940a7128698a78b94d59680176f7700160 (patch)
treed7025ee1646b806f56f2d218599013aa57dae510 /cloud_print
parente996309dfa0c63357ce381d7740301ab8b1c3cec (diff)
downloadchromium_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')
-rw-r--r--cloud_print/gcp20/prototype/gcp20_device.cc27
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;