Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: apps/app_shim/app_shim_host_controller.mm

Issue 12623005: [mac] App shims (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move app_shim code to apps/ Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "apps/app_shim/app_shim_host_controller.h"
6
7 #include "apps/app_shim/app_shim_host.h"
8 #include "base/bind.h"
9 #include "base/files/file_path.h"
10 #include "base/logging.h"
11 #include "base/path_service.h"
12 #include "chrome/browser/browser_process.h"
13 #include "chrome/common/chrome_paths.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "chrome/common/mac/app_mode_common.h"
16
17 using content::BrowserThread;
18
19 namespace {
20
21 void CreateAppShimHost(const IPC::ChannelHandle& handle) {
22 AppShimHost* host = new AppShimHost;
23 host->ServeChannel(handle);
koz (OOO until 15th September) 2013/03/14 23:51:05 nit: make this one line? Also, add a comment sayi
jeremya 2013/03/15 02:24:14 Done.
24 }
25
26 } // namespace
27
28 AppShimHostController::AppShimHostController() : factory_(NULL) {
koz (OOO until 15th September) 2013/03/14 23:51:05 DCHECK() to communicate what thread this is suppos
jeremya 2013/03/15 02:24:14 Done.
29 BrowserThread::PostTask(
30 BrowserThread::FILE, FROM_HERE,
31 base::Bind(&AppShimHostController::InitOnFileThread,
32 base::Unretained(this)));
33 }
34
35 AppShimHostController::~AppShimHostController() {
36 delete factory_;
koz (OOO until 15th September) 2013/03/14 23:51:05 scoped_ptr for factory_.
jeremya 2013/03/15 02:24:14 Done.
37 }
38
39 void AppShimHostController::InitOnFileThread() {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
41 base::FilePath user_data_dir;
42 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
43 LOG(ERROR) << "Couldn't get user data directory while creating App Shim "
44 << "Host controller.";
45 return;
46 }
47 base::FilePath socket_path =
48 user_data_dir.Append(app_mode::kAppShimSocketName);
49 factory_ = new IPC::ChannelFactory(socket_path, this);
50 BrowserThread::PostTask(
51 BrowserThread::IO, FROM_HERE,
52 base::Bind(&AppShimHostController::ListenOnIOThread,
53 base::Unretained(this)));
54 }
55
56 void AppShimHostController::ListenOnIOThread() {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
58 factory_->Listen();
59 }
60
61 void AppShimHostController::OnClientConnected(
62 const IPC::ChannelHandle& handle) {
63 // called on IO thread
koz (OOO until 15th September) 2013/03/14 23:51:05 DCHECK() that we're on the IO thread rather than t
jeremya 2013/03/15 02:24:14 Done.
64 BrowserThread::PostTask(
65 BrowserThread::UI, FROM_HERE,
66 base::Bind(&CreateAppShimHost, handle));
67 }
68
69 void AppShimHostController::OnListenError() {
70 // TODO(jeremya): set a timeout and attempt to reconstruct the channel.
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698