12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
51320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#ifndef EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_EXTENSION_FUNCTION_H_
61320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#define EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_EXTENSION_FUNCTION_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/ref_counted.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/weak_ptr.h"
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "extensions/browser/extension_function.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace device {
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class BluetoothAdapter;
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace device
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace extensions {
191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace core_api {
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Base class for bluetooth extension functions. This class initializes
22c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// bluetooth adapter and calls (on the UI thread) DoWork() implemented by
23c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// individual bluetooth extension functions.
24010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)class BluetoothExtensionFunction : public AsyncExtensionFunction {
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  BluetoothExtensionFunction();
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected:
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~BluetoothExtensionFunction();
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // ExtensionFunction:
32010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  virtual bool RunAsync() OVERRIDE;
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void RunOnAdapterReady(scoped_refptr<device::BluetoothAdapter> adapter);
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Implemented by individual bluetooth extension functions, called
38c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  // automatically on the UI thread once |adapter| has been initialized.
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) = 0;
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(BluetoothExtensionFunction);
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}  // namespace core_api
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace extensions
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif  // EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_EXTENSION_FUNCTION_H_
48