blob: 7052bbe42f99b97fdec462b2243bc64c9a3f2f51 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_BROWSER_API_HID_HID_CONNECTION_RESOURCE_H_
#define EXTENSIONS_BROWSER_API_HID_HID_CONNECTION_RESOURCE_H_
#include <string>
#include "base/memory/ref_counted.h"
#include "content/public/browser/browser_thread.h"
#include "device/hid/hid_connection.h"
#include "extensions/browser/api/api_resource.h"
#include "extensions/browser/api/api_resource_manager.h"
namespace device {
class HidConnection;
}
namespace extensions {
class HidConnectionResource : public ApiResource {
public:
#if defined(OS_MACOSX)
// Migration from FILE thread to UI thread. OS X gets it first.
static const content::BrowserThread::ID kThreadId =
content::BrowserThread::UI;
#else
// TODO(reillyg): Migrate Linux/CrOS and Windows as well.
static const content::BrowserThread::ID kThreadId =
content::BrowserThread::FILE;
#endif
HidConnectionResource(const std::string& owner_extension_id,
scoped_refptr<device::HidConnection> connection);
virtual ~HidConnectionResource();
scoped_refptr<device::HidConnection> connection() const {
return connection_;
}
virtual bool IsPersistent() const OVERRIDE;
static const char* service_name() { return "HidConnectionResourceManager"; }
private:
scoped_refptr<device::HidConnection> connection_;
DISALLOW_COPY_AND_ASSIGN(HidConnectionResource);
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_API_HID_HID_CONNECTION_RESOURCE_H_