diff options
author | maksymb@chromium.org <maksymb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-22 16:49:06 +0000 |
---|---|---|
committer | maksymb@chromium.org <maksymb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-22 16:49:06 +0000 |
commit | ead61a438feb008581b82fddca34a18527c868d1 (patch) | |
tree | 97fee11962961af87dca2f24401c92eabfcebb7b /cloud_print/gcp20/prototype/gcp20_device.cc | |
parent | 98751ff18ca3721338c6103d8f78d09dcb6e2a53 (diff) | |
download | chromium_src-ead61a438feb008581b82fddca34a18527c868d1.zip chromium_src-ead61a438feb008581b82fddca34a18527c868d1.tar.gz chromium_src-ead61a438feb008581b82fddca34a18527c868d1.tar.bz2 |
Finished DNS-SD server. Finished Privet-specified DNS-SD server.
Review URL: https://chromiumcodereview.appspot.com/16975004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208064 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print/gcp20/prototype/gcp20_device.cc')
-rw-r--r-- | cloud_print/gcp20/prototype/gcp20_device.cc | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/cloud_print/gcp20/prototype/gcp20_device.cc b/cloud_print/gcp20/prototype/gcp20_device.cc index 2ff1a2d..4eab248 100644 --- a/cloud_print/gcp20/prototype/gcp20_device.cc +++ b/cloud_print/gcp20/prototype/gcp20_device.cc @@ -2,12 +2,40 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <stdio.h> +#include <signal.h> +#include "base/at_exit.h" +#include "base/bind.h" #include "base/command_line.h" #include "base/logging.h" +#include "base/message_loop.h" +#include "base/run_loop.h" #include "base/threading/platform_thread.h" -#include "cloud_print/gcp20/prototype/dns_sd_server.h" +#include "base/time.h" +#include "cloud_print/gcp20/prototype/printer.h" + +namespace { + +Printer printer; +base::AtExitManager at_exit; + +void StopPrinter() { + printer.Stop(); +} + +void StartPrinter() { + bool success = printer.Start(); + DCHECK(success); + + at_exit.RegisterTask(base::Bind(&StopPrinter)); +} + +void OnAbort(int val) { + StopPrinter(); + base::MessageLoop::current()->Quit(); +} + +} // namespace int main(int argc, char* argv[]) { CommandLine::Init(argc, argv); @@ -16,11 +44,12 @@ int main(int argc, char* argv[]) { settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; logging::InitLogging(settings); - DnsSdServer dns_sd_server; - dns_sd_server.Start(); - base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(2)); - dns_sd_server.Shutdown(); + signal(SIGINT, OnAbort); // Handle Ctrl+C signal. + + base::MessageLoop loop(base::MessageLoop::TYPE_IO); + base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&StartPrinter)); + base::RunLoop runner; + runner.Run(); return 0; } - |