| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cloud_print/service/win/service_listener.h" | 5 #include "cloud_print/service/win/service_listener.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 base::Bind(&ServiceListener::Disconnect, | 68 base::Bind(&ServiceListener::Disconnect, |
| 69 base::Unretained(this))); | 69 base::Unretained(this))); |
| 70 ipc_thread_->Stop(); | 70 ipc_thread_->Stop(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool ServiceListener::OnMessageReceived(const IPC::Message& msg) { | 73 bool ServiceListener::OnMessageReceived(const IPC::Message& msg) { |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void ServiceListener::OnChannelConnected(int32 peer_pid) { | 77 void ServiceListener::OnChannelConnected(int32 peer_pid) { |
| 78 IPC::Message* message = new IPC::Message(0, 0); | 78 IPC::Message* message = new IPC::Message(0, 0, IPC::Message::PRIORITY_NORMAL); |
| 79 message->WriteString(GetEnvironment(user_data_dir_)); | 79 message->WriteString(GetEnvironment(user_data_dir_)); |
| 80 channel_->Send(message); | 80 channel_->Send(message); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ServiceListener::Disconnect() { | 83 void ServiceListener::Disconnect() { |
| 84 channel_.reset(); | 84 channel_.reset(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void ServiceListener::Connect() { | 87 void ServiceListener::Connect() { |
| 88 base::win::ScopedHandle handle( | 88 base::win::ScopedHandle handle( |
| 89 ::CreateFile(SetupListener::kSetupPipeName, GENERIC_READ | GENERIC_WRITE, | 89 ::CreateFile(SetupListener::kSetupPipeName, GENERIC_READ | GENERIC_WRITE, |
| 90 0, NULL, OPEN_EXISTING, | 90 0, NULL, OPEN_EXISTING, |
| 91 SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION | | 91 SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION | |
| 92 FILE_FLAG_OVERLAPPED, NULL)); | 92 FILE_FLAG_OVERLAPPED, NULL)); |
| 93 if (handle.IsValid()) { | 93 if (handle.IsValid()) { |
| 94 channel_.reset(new IPC::Channel(IPC::ChannelHandle(handle), | 94 channel_.reset(new IPC::Channel(IPC::ChannelHandle(handle), |
| 95 IPC::Channel::MODE_CLIENT, this)); | 95 IPC::Channel::MODE_CLIENT, this)); |
| 96 channel_->Connect(); | 96 channel_->Connect(); |
| 97 } else { | 97 } else { |
| 98 ipc_thread_->message_loop()->PostDelayedTask( | 98 ipc_thread_->message_loop()->PostDelayedTask( |
| 99 FROM_HERE, | 99 FROM_HERE, |
| 100 base::Bind(&ServiceListener::Connect, base::Unretained(this)), | 100 base::Bind(&ServiceListener::Connect, base::Unretained(this)), |
| 101 base::TimeDelta::FromMilliseconds(500)); | 101 base::TimeDelta::FromMilliseconds(500)); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| OLD | NEW |