OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/viewer/viewer_process_host.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "chrome/common/viewer_messages.h" | |
9 #include "content/public/browser/browser_thread.h" | |
10 #include "ipc/ipc_channel.h" | |
11 #include "ui/surface/accelerated_surface_win.h" | |
12 | |
13 namespace viewer { | |
14 | |
15 ViewerProcessHost::ViewerProcessHost() { | |
16 DVLOG(ERROR) << __FUNCTION__ << ", ViewerProcessHost"; | |
jam
2012/09/27 21:18:40
error?
scottmg
2012/09/28 04:50:45
Done. (deleted)
| |
17 content::BrowserThread::PostTask( | |
18 content::BrowserThread::IO, FROM_HERE, base::Bind( | |
19 &ViewerProcessHost::CreateChannel, base::Unretained(this))); | |
jam
2012/09/27 21:18:40
how is this safe (i.e. that this object is deleted
scottmg
2012/09/28 04:50:45
Done.
| |
20 } | |
21 | |
22 ViewerProcessHost::~ViewerProcessHost() { | |
23 } | |
24 | |
25 bool ViewerProcessHost::Send(IPC::Message* msg) { | |
26 return false; | |
jam
2012/09/27 21:18:40
nit: return channel_->Send(msg)?
scottmg
2012/09/28 04:50:45
Done.
| |
27 } | |
28 | |
29 bool ViewerProcessHost::OnMessageReceived(const IPC::Message& message) { | |
30 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | |
31 bool handled = true; | |
32 IPC_BEGIN_MESSAGE_MAP(ViewerProcessHost, message) | |
33 IPC_MESSAGE_HANDLER(ViewerHostMsg_SetTargetSurface, OnSetTargetSurface) | |
34 IPC_MESSAGE_UNHANDLED(handled = false) | |
35 IPC_END_MESSAGE_MAP() | |
36 return handled; | |
37 } | |
38 | |
39 void ViewerProcessHost::OnChannelConnected(int32 peer_pid) { | |
40 NOTIMPLEMENTED(); | |
jam
2012/09/27 21:18:40
nit: if you don't need these, no need to override
scottmg
2012/09/28 04:50:45
Done.
| |
41 } | |
42 | |
43 void ViewerProcessHost::OnChannelError() { | |
44 NOTIMPLEMENTED(); | |
45 } | |
46 | |
47 void ViewerProcessHost::OnSetTargetSurface(uint32 target_surface) { | |
48 DVLOG(ERROR) << __FUNCTION__ << target_surface; | |
49 HWND hwnd = reinterpret_cast<HWND>(target_surface); | |
50 | |
51 scoped_refptr<AcceleratedPresenter> any_window = | |
52 AcceleratedPresenter::GetForWindow(NULL); | |
53 any_window->SetNewTargetWindow(hwnd); | |
54 } | |
55 | |
56 void ViewerProcessHost::CreateChannel() { | |
57 DVLOG(ERROR) << __FUNCTION__ << ", in browser"; | |
58 channel_.reset(new IPC::Channel( | |
59 "viewer", IPC::Channel::MODE_NAMED_SERVER, this)); | |
60 DVLOG(ERROR) << __FUNCTION__ << ", calling Connect"; | |
61 if (!channel_->Connect()) { | |
62 DVLOG(ERROR) << "Couldn't connect."; | |
63 } | |
64 DVLOG(ERROR) << __FUNCTION__ << ", done"; | |
65 } | |
66 | |
67 } // namespace viewer | |
OLD | NEW |