Merge from Chromium at DEPS revision 251904

This commit was generated by merge_to_master.py.

Change-Id: I1f9543259d7d2a57d81aa41a1b84f85837439d21
diff --git a/device/bluetooth/bluetooth.gyp b/device/bluetooth/bluetooth.gyp
index c5d8cad..c4012bd 100644
--- a/device/bluetooth/bluetooth.gyp
+++ b/device/bluetooth/bluetooth.gyp
@@ -16,6 +16,7 @@
         '../../net/net.gyp:net',
         '../../third_party/libxml/libxml.gyp:libxml',
         '../../ui/gfx/gfx.gyp:gfx',
+        '../../ui/gfx/gfx.gyp:gfx_geometry',
         '../../ui/ui.gyp:ui',
         'bluetooth_strings.gyp:device_bluetooth_strings',
       ],
@@ -38,6 +39,12 @@
         'bluetooth_device_mac.mm',
         'bluetooth_device_win.cc',
         'bluetooth_device_win.h',
+        'bluetooth_gatt_characteristic.cc',
+        'bluetooth_gatt_characteristic.h',
+        'bluetooth_gatt_descriptor.cc',
+        'bluetooth_gatt_descriptor.h',
+        'bluetooth_gatt_service.cc',
+        'bluetooth_gatt_service.h',
         'bluetooth_init_win.cc',
         'bluetooth_init_win.h',
         'bluetooth_out_of_band_pairing_data.h',
diff --git a/device/bluetooth/bluetooth_adapter.h b/device/bluetooth/bluetooth_adapter.h
index ed61586..24e9dcd 100644
--- a/device/bluetooth/bluetooth_adapter.h
+++ b/device/bluetooth/bluetooth_adapter.h
@@ -43,6 +43,12 @@
     virtual void AdapterPoweredChanged(BluetoothAdapter* adapter,
                                        bool powered) {}
 
+    // Called when the discoverability state of the  adapter |adapter| changes,
+    // when |discoverable| is true the adapter is discoverable by other devices,
+    // false means the adapter is not discoverable.
+    virtual void AdapterDiscoverableChanged(BluetoothAdapter* adapter,
+                                           bool discoverable) {}
+
     // Called when the discovering state of the adapter |adapter| changes,
     // when |discovering| is true the adapter is seeking new devices, false
     // means it is not.
@@ -91,6 +97,12 @@
   // The name of the adapter.
   virtual std::string GetName() const = 0;
 
+  // Set the human-readable name of the adapter to |name|. On success,
+  // |callback| will be called. On failure, |error_callback| will be called.
+  virtual void SetName(const std::string& name,
+                       const base::Closure& callback,
+                       const ErrorCallback& error_callback) = 0;
+
   // Indicates whether the adapter is initialized and ready to use.
   virtual bool IsInitialized() const = 0;
 
@@ -109,6 +121,17 @@
                           const base::Closure& callback,
                           const ErrorCallback& error_callback) = 0;
 
+  // Indicates whether the adapter radio is discoverable.
+  virtual bool IsDiscoverable() const = 0;
+
+  // Requests that the adapter change its discoverability state. If
+  // |discoverable| is true, then it will be discoverable by other Bluetooth
+  // devices. On successly changing the adapter's discoverability, |callback|
+  // will be called. On failure, |error_callback| will be called.
+  virtual void SetDiscoverable(bool discoverable,
+                               const base::Closure& callback,
+                               const ErrorCallback& error_callback) = 0;
+
   // Indicates whether the adapter is currently discovering new devices.
   virtual bool IsDiscovering() const = 0;
 
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc
index 319a6e9..0d962b9 100644
--- a/device/bluetooth/bluetooth_adapter_chromeos.cc
+++ b/device/bluetooth/bluetooth_adapter_chromeos.cc
@@ -79,6 +79,18 @@
   return properties->alias.value();
 }
 
+void BluetoothAdapterChromeOS::SetName(const std::string& name,
+                                       const base::Closure& callback,
+                                       const ErrorCallback& error_callback) {
+  DBusThreadManager::Get()->GetBluetoothAdapterClient()->
+      GetProperties(object_path_)->alias.Set(
+          name,
+          base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted,
+                     weak_ptr_factory_.GetWeakPtr(),
+                     callback,
+                     error_callback));
+}
+
 bool BluetoothAdapterChromeOS::IsInitialized() const {
   return true;
 }
@@ -105,7 +117,31 @@
   DBusThreadManager::Get()->GetBluetoothAdapterClient()->
       GetProperties(object_path_)->powered.Set(
           powered,
-          base::Bind(&BluetoothAdapterChromeOS::OnSetPowered,
+          base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted,
+                     weak_ptr_factory_.GetWeakPtr(),
+                     callback,
+                     error_callback));
+}
+
+bool BluetoothAdapterChromeOS::IsDiscoverable() const {
+  if (!IsPresent())
+    return false;
+
+  BluetoothAdapterClient::Properties* properties =
+      DBusThreadManager::Get()->GetBluetoothAdapterClient()->
+          GetProperties(object_path_);
+
+  return properties->discoverable.value();
+}
+
+void BluetoothAdapterChromeOS::SetDiscoverable(
+    bool discoverable,
+    const base::Closure& callback,
+    const ErrorCallback& error_callback) {
+  DBusThreadManager::Get()->GetBluetoothAdapterClient()->
+      GetProperties(object_path_)->discoverable.Set(
+          discoverable,
+          base::Bind(&BluetoothAdapterChromeOS::OnSetDiscoverable,
                      weak_ptr_factory_.GetWeakPtr(),
                      callback,
                      error_callback));
@@ -185,6 +221,8 @@
 
   if (property_name == properties->powered.name())
     PoweredChanged(properties->powered.value());
+  else if (property_name == properties->discoverable.name())
+    DiscoverableChanged(properties->discoverable.value());
   else if (property_name == properties->discovering.name())
     DiscoveringChanged(properties->discovering.value());
 }
@@ -297,7 +335,7 @@
 
   VLOG(1) << object_path_.value() << ": using adapter.";
 
-  SetAdapterName();
+  SetDefaultAdapterName();
 
   BluetoothAdapterClient::Properties* properties =
       DBusThreadManager::Get()->GetBluetoothAdapterClient()->
@@ -307,6 +345,8 @@
 
   if (properties->powered.value())
     PoweredChanged(true);
+  if (properties->discoverable.value())
+    DiscoverableChanged(true);
   if (properties->discovering.value())
     DiscoveringChanged(true);
 
@@ -326,7 +366,7 @@
   }
 }
 
-void BluetoothAdapterChromeOS::SetAdapterName() {
+void BluetoothAdapterChromeOS::SetDefaultAdapterName() {
   std::string board = base::SysInfo::GetLsbReleaseBoard();
   std::string alias;
   if (board.substr(0, 6) == "stumpy") {
@@ -337,16 +377,7 @@
     alias = "Chromebook";
   }
 
-  DBusThreadManager::Get()->GetBluetoothAdapterClient()->
-      GetProperties(object_path_)->alias.Set(
-          alias,
-          base::Bind(&BluetoothAdapterChromeOS::OnSetAlias,
-                     weak_ptr_factory_.GetWeakPtr()));
-}
-
-void BluetoothAdapterChromeOS::OnSetAlias(bool success) {
-  LOG_IF(WARNING, !success) << object_path_.value()
-                            << ": Failed to set adapter alias";
+  SetName(alias, base::Bind(&base::DoNothing), base::Bind(&base::DoNothing));
 }
 
 void BluetoothAdapterChromeOS::RemoveAdapter() {
@@ -361,6 +392,8 @@
 
   if (properties->powered.value())
     PoweredChanged(false);
+  if (properties->discoverable.value())
+    DiscoverableChanged(false);
   if (properties->discovering.value())
     DiscoveringChanged(false);
 
@@ -384,6 +417,11 @@
                     AdapterPoweredChanged(this, powered));
 }
 
+void BluetoothAdapterChromeOS::DiscoverableChanged(bool discoverable) {
+  FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
+                    AdapterDiscoverableChanged(this, discoverable));
+}
+
 void BluetoothAdapterChromeOS::DiscoveringChanged(
     bool discovering) {
   FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
@@ -403,9 +441,25 @@
                     DeviceChanged(this, device));
 }
 
-void BluetoothAdapterChromeOS::OnSetPowered(const base::Closure& callback,
-                                            const ErrorCallback& error_callback,
-                                            bool success) {
+void BluetoothAdapterChromeOS::OnSetDiscoverable(
+    const base::Closure& callback,
+    const ErrorCallback& error_callback,
+    bool success) {
+  // Set the discoverable_timeout property to zero so the adapter remains
+  // discoverable forever.
+  DBusThreadManager::Get()->GetBluetoothAdapterClient()->
+      GetProperties(object_path_)->discoverable_timeout.Set(
+          0,
+          base::Bind(&BluetoothAdapterChromeOS::OnPropertyChangeCompleted,
+                     weak_ptr_factory_.GetWeakPtr(),
+                     callback,
+                     error_callback));
+}
+
+void BluetoothAdapterChromeOS::OnPropertyChangeCompleted(
+    const base::Closure& callback,
+    const ErrorCallback& error_callback,
+    bool success) {
   if (success)
     callback.Run();
   else
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.h b/device/bluetooth/bluetooth_adapter_chromeos.h
index 74beb35..b400ed3 100644
--- a/device/bluetooth/bluetooth_adapter_chromeos.h
+++ b/device/bluetooth/bluetooth_adapter_chromeos.h
@@ -40,6 +40,9 @@
       device::BluetoothAdapter::Observer* observer) OVERRIDE;
   virtual std::string GetAddress() const OVERRIDE;
   virtual std::string GetName() const OVERRIDE;
+  virtual void SetName(const std::string& name,
+                       const base::Closure& callback,
+                       const ErrorCallback& error_callback) OVERRIDE;
   virtual bool IsInitialized() const OVERRIDE;
   virtual bool IsPresent() const OVERRIDE;
   virtual bool IsPowered() const OVERRIDE;
@@ -47,6 +50,11 @@
       bool powered,
       const base::Closure& callback,
       const ErrorCallback& error_callback) OVERRIDE;
+  virtual bool IsDiscoverable() const OVERRIDE;
+  virtual void SetDiscoverable(
+      bool discoverable,
+      const base::Closure& callback,
+      const ErrorCallback& error_callback) OVERRIDE;
   virtual bool IsDiscovering() const OVERRIDE;
   virtual void StartDiscovering(
       const base::Closure& callback,
@@ -95,10 +103,8 @@
   // subsequently operate on that adapter until it is removed.
   void SetAdapter(const dbus::ObjectPath& object_path);
 
-  // Set the adapter name to one chosen from the system information, and method
-  // called by dbus:: on completion of the alias property change.
-  void SetAdapterName();
-  void OnSetAlias(bool success);
+  // Set the adapter name to one chosen from the system information.
+  void SetDefaultAdapterName();
 
   // Remove the currently tracked adapter. IsPresent() will return false after
   // this is called.
@@ -106,6 +112,7 @@
 
   // Announce to observers a change in the adapter state.
   void PoweredChanged(bool powered);
+  void DiscoverableChanged(bool discoverable);
   void DiscoveringChanged(bool discovering);
   void PresentChanged(bool present);
 
@@ -113,10 +120,15 @@
   // its D-Bus properties.
   void NotifyDeviceChanged(BluetoothDeviceChromeOS* device);
 
-  // Called by dbus:: on completion of the powered property change.
-  void OnSetPowered(const base::Closure& callback,
-                    const ErrorCallback& error_callback,
-                    bool success);
+  // Called by dbus:: on completion of the discoverable property change.
+  void OnSetDiscoverable(const base::Closure& callback,
+                         const ErrorCallback& error_callback,
+                         bool success);
+
+  // Called by dbus:: on completion of an adapter property change.
+  void OnPropertyChangeCompleted(const base::Closure& callback,
+                                 const ErrorCallback& error_callback,
+                                 bool success);
 
   // Called by dbus:: on completion of the D-Bus method call to start discovery.
   void OnStartDiscovery(const base::Closure& callback);
diff --git a/device/bluetooth/bluetooth_adapter_mac.h b/device/bluetooth/bluetooth_adapter_mac.h
index 7054acf..6639db0 100644
--- a/device/bluetooth/bluetooth_adapter_mac.h
+++ b/device/bluetooth/bluetooth_adapter_mac.h
@@ -47,6 +47,9 @@
   virtual void RemoveObserver(BluetoothAdapter::Observer* observer) OVERRIDE;
   virtual std::string GetAddress() const OVERRIDE;
   virtual std::string GetName() const OVERRIDE;
+  virtual void SetName(const std::string& name,
+                       const base::Closure& callback,
+                       const ErrorCallback& error_callback) OVERRIDE;
   virtual bool IsInitialized() const OVERRIDE;
   virtual bool IsPresent() const OVERRIDE;
   virtual bool IsPowered() const OVERRIDE;
@@ -54,6 +57,11 @@
       bool powered,
       const base::Closure& callback,
       const ErrorCallback& error_callback) OVERRIDE;
+  virtual bool IsDiscoverable() const OVERRIDE;
+  virtual void SetDiscoverable(
+      bool discoverable,
+      const base::Closure& callback,
+      const ErrorCallback& error_callback) OVERRIDE;
   virtual bool IsDiscovering() const OVERRIDE;
 
   virtual void StartDiscovering(
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index e15b894..502ed81 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -127,6 +127,12 @@
   return name_;
 }
 
+void BluetoothAdapterMac::SetName(const std::string& name,
+                                  const base::Closure& callback,
+                                  const ErrorCallback& error_callback) {
+  NOTIMPLEMENTED();
+}
+
 bool BluetoothAdapterMac::IsInitialized() const {
   return true;
 }
@@ -142,6 +148,19 @@
 void BluetoothAdapterMac::SetPowered(bool powered,
                                      const base::Closure& callback,
                                      const ErrorCallback& error_callback) {
+  NOTIMPLEMENTED();
+}
+
+bool BluetoothAdapterMac::IsDiscoverable() const {
+  NOTIMPLEMENTED();
+  return false;
+}
+
+void BluetoothAdapterMac::SetDiscoverable(
+    bool discoverable,
+    const base::Closure& callback,
+    const ErrorCallback& error_callback) {
+  NOTIMPLEMENTED();
 }
 
 bool BluetoothAdapterMac::IsDiscovering() const {
diff --git a/device/bluetooth/bluetooth_adapter_win.cc b/device/bluetooth/bluetooth_adapter_win.cc
index f6ca1d6..521afae 100644
--- a/device/bluetooth/bluetooth_adapter_win.cc
+++ b/device/bluetooth/bluetooth_adapter_win.cc
@@ -53,6 +53,12 @@
   return name_;
 }
 
+void BluetoothAdapterWin::SetName(const std::string& name,
+                                  const base::Closure& callback,
+                                  const ErrorCallback& error_callback) {
+  NOTIMPLEMENTED();
+}
+
 // TODO(youngki): Return true when |task_manager_| initializes the adapter
 // state.
 bool BluetoothAdapterWin::IsInitialized() const {
@@ -74,6 +80,18 @@
   task_manager_->PostSetPoweredBluetoothTask(powered, callback, error_callback);
 }
 
+bool BluetoothAdapterWin::IsDiscoverable() const {
+  NOTIMPLEMENTED();
+  return false;
+}
+
+void BluetoothAdapterWin::SetDiscoverable(
+    bool discoverable,
+    const base::Closure& callback,
+    const ErrorCallback& error_callback) {
+  NOTIMPLEMENTED();
+}
+
 bool BluetoothAdapterWin::IsDiscovering() const {
   return discovery_status_ == DISCOVERING ||
       discovery_status_ == DISCOVERY_STOPPING;
diff --git a/device/bluetooth/bluetooth_adapter_win.h b/device/bluetooth/bluetooth_adapter_win.h
index a017e29..773c6f3 100644
--- a/device/bluetooth/bluetooth_adapter_win.h
+++ b/device/bluetooth/bluetooth_adapter_win.h
@@ -39,11 +39,19 @@
   virtual void RemoveObserver(BluetoothAdapter::Observer* observer) OVERRIDE;
   virtual std::string GetAddress() const OVERRIDE;
   virtual std::string GetName() const OVERRIDE;
+  virtual void SetName(const std::string& name,
+                       const base::Closure& callback,
+                       const ErrorCallback& error_callback) OVERRIDE;
   virtual bool IsInitialized() const OVERRIDE;
   virtual bool IsPresent() const OVERRIDE;
   virtual bool IsPowered() const OVERRIDE;
   virtual void SetPowered(
-      bool powered,
+      bool discoverable,
+      const base::Closure& callback,
+      const ErrorCallback& error_callback) OVERRIDE;
+  virtual bool IsDiscoverable() const OVERRIDE;
+  virtual void SetDiscoverable(
+      bool discoverable,
       const base::Closure& callback,
       const ErrorCallback& error_callback) OVERRIDE;
   virtual bool IsDiscovering() const OVERRIDE;
diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_chromeos_unittest.cc
index dea1322..a1cc67d 100644
--- a/device/bluetooth/bluetooth_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_chromeos_unittest.cc
@@ -28,6 +28,7 @@
   TestObserver(scoped_refptr<BluetoothAdapter> adapter)
       : present_changed_count_(0),
         powered_changed_count_(0),
+        discoverable_changed_count_(0),
         discovering_changed_count_(0),
         last_present_(false),
         last_powered_(false),
@@ -56,6 +57,13 @@
     last_powered_ = powered;
   }
 
+  virtual void AdapterDiscoverableChanged(BluetoothAdapter* adapter,
+                                          bool discoverable) OVERRIDE {
+    EXPECT_EQ(adapter_, adapter);
+
+    ++discoverable_changed_count_;
+  }
+
   virtual void AdapterDiscoveringChanged(BluetoothAdapter* adapter,
                                          bool discovering) OVERRIDE {
     EXPECT_EQ(adapter_, adapter);
@@ -99,6 +107,7 @@
 
   int present_changed_count_;
   int powered_changed_count_;
+  int discoverable_changed_count_;
   int discovering_changed_count_;
   bool last_present_;
   bool last_powered_;
@@ -264,7 +273,7 @@
     ASSERT_TRUE(adapter_.get() != NULL);
 
     if (base::MessageLoop::current() == NULL) {
-      base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+      base::MessageLoop message_loop;
       DiscoverDevices();
       return;
     }
@@ -507,8 +516,81 @@
   EXPECT_FALSE(adapter_->IsPowered());
 }
 
+TEST_F(BluetoothChromeOSTest, ChangeAdapterName) {
+  GetAdapter();
+
+  static const std::string new_name(".__.");
+
+  adapter_->SetName(
+      new_name,
+      base::Bind(&BluetoothChromeOSTest::Callback,
+                 base::Unretained(this)),
+      base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+                 base::Unretained(this)));
+  EXPECT_EQ(1, callback_count_);
+  EXPECT_EQ(0, error_callback_count_);
+
+  EXPECT_EQ(new_name, adapter_->GetName());
+}
+
+TEST_F(BluetoothChromeOSTest, BecomeDiscoverable) {
+  GetAdapter();
+  ASSERT_FALSE(adapter_->IsDiscoverable());
+
+  // Install an observer; expect the AdapterDiscoverableChanged to be called
+  // with true, and IsDiscoverable() to return true.
+  TestObserver observer(adapter_);
+  adapter_->AddObserver(&observer);
+
+  adapter_->SetDiscoverable(
+      true,
+      base::Bind(&BluetoothChromeOSTest::Callback,
+                 base::Unretained(this)),
+      base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+                 base::Unretained(this)));
+  EXPECT_EQ(1, callback_count_);
+  EXPECT_EQ(0, error_callback_count_);
+
+  EXPECT_EQ(1, observer.discoverable_changed_count_);
+
+  EXPECT_TRUE(adapter_->IsDiscoverable());
+}
+
+TEST_F(BluetoothChromeOSTest, BecomeNotDiscoverable) {
+  GetAdapter();
+  adapter_->SetDiscoverable(
+      true,
+      base::Bind(&BluetoothChromeOSTest::Callback,
+                 base::Unretained(this)),
+      base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+                 base::Unretained(this)));
+  EXPECT_EQ(1, callback_count_);
+  EXPECT_EQ(0, error_callback_count_);
+  callback_count_ = 0;
+
+  ASSERT_TRUE(adapter_->IsDiscoverable());
+
+  // Install an observer; expect the AdapterDiscoverableChanged to be called
+  // with false, and IsDiscoverable() to return false.
+  TestObserver observer(adapter_);
+  adapter_->AddObserver(&observer);
+
+  adapter_->SetDiscoverable(
+      false,
+      base::Bind(&BluetoothChromeOSTest::Callback,
+                 base::Unretained(this)),
+      base::Bind(&BluetoothChromeOSTest::ErrorCallback,
+                 base::Unretained(this)));
+  EXPECT_EQ(1, callback_count_);
+  EXPECT_EQ(0, error_callback_count_);
+
+  EXPECT_EQ(1, observer.discoverable_changed_count_);
+
+  EXPECT_FALSE(adapter_->IsDiscoverable());
+}
+
 TEST_F(BluetoothChromeOSTest, StopDiscovery) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
 
   GetAdapter();
 
@@ -551,7 +633,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, StopDiscoveryAfterTwoStarts) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
 
   GetAdapter();
 
@@ -623,7 +705,7 @@
 
 TEST_F(BluetoothChromeOSTest, Discovery) {
   // Test a simulated discovery session.
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
 
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
   GetAdapter();
@@ -670,7 +752,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PoweredAndDiscovering) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
 
   GetAdapter();
   adapter_->SetPowered(
@@ -749,7 +831,7 @@
             devices[0]->GetAddress());
 
   // Verify the other device properties.
-  EXPECT_EQ(UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName),
+  EXPECT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName),
             devices[0]->GetName());
   EXPECT_EQ(BluetoothDevice::DEVICE_COMPUTER, devices[0]->GetDeviceType());
   EXPECT_TRUE(devices[0]->IsPaired());
@@ -805,7 +887,7 @@
   ASSERT_EQ(1U, devices.size());
   ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress,
             devices[0]->GetAddress());
-  ASSERT_EQ(UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName),
+  ASSERT_EQ(base::UTF8ToUTF16(FakeBluetoothDeviceClient::kPairedDeviceName),
             devices[0]->GetName());
 
   // Install an observer; expect the DeviceChanged method to be called when
@@ -823,7 +905,7 @@
   EXPECT_EQ(1, observer.device_changed_count_);
   EXPECT_EQ(devices[0], observer.last_device_);
 
-  EXPECT_EQ(UTF8ToUTF16(new_name), devices[0]->GetName());
+  EXPECT_EQ(base::UTF8ToUTF16(new_name), devices[0]->GetName());
 }
 
 TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) {
@@ -1169,7 +1251,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairAppleMouse) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1230,7 +1312,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairAppleKeyboard) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1292,7 +1374,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairMotorolaKeyboard) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1375,7 +1457,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairSonyHeadphones) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1438,7 +1520,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairPhone) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1498,7 +1580,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairWeirdDevice) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1559,7 +1641,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairUnpairableDeviceFails) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1602,7 +1684,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairingFails) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1646,7 +1728,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairingFailsAtConnection) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1703,7 +1785,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPinCode) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1750,7 +1832,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPinCode) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1797,7 +1879,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairingRejectedAtPasskey) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1844,7 +1926,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairingCancelledAtPasskey) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1891,7 +1973,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairingRejectedAtConfirmation) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1938,7 +2020,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairingCancelledAtConfirmation) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
@@ -1985,7 +2067,7 @@
 }
 
 TEST_F(BluetoothChromeOSTest, PairingCancelledInFlight) {
-  base::MessageLoop message_loop(base::MessageLoop::TYPE_DEFAULT);
+  base::MessageLoop message_loop;
   fake_bluetooth_device_client_->SetSimulationIntervalMs(10);
 
   GetAdapter();
diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc
index 7b6ee0d..7c100ec 100644
--- a/device/bluetooth/bluetooth_device.cc
+++ b/device/bluetooth/bluetooth_device.cc
@@ -24,17 +24,17 @@
 BluetoothDevice::~BluetoothDevice() {
 }
 
-string16 BluetoothDevice::GetName() const {
+base::string16 BluetoothDevice::GetName() const {
   std::string name = GetDeviceName();
   if (!name.empty()) {
-    return UTF8ToUTF16(name);
+    return base::UTF8ToUTF16(name);
   } else {
     return GetAddressWithLocalizedDeviceTypeName();
   }
 }
 
-string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const {
-  string16 address_utf16 = UTF8ToUTF16(GetAddress());
+base::string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const {
+  base::string16 address_utf16 = base::UTF8ToUTF16(GetAddress());
   BluetoothDevice::DeviceType device_type = GetDeviceType();
   switch (device_type) {
     case DEVICE_COMPUTER:
diff --git a/device/bluetooth/bluetooth_device.h b/device/bluetooth/bluetooth_device.h
index aaf4e93..95fe683 100644
--- a/device/bluetooth/bluetooth_device.h
+++ b/device/bluetooth/bluetooth_device.h
@@ -188,7 +188,7 @@
   // Returns the name of the device suitable for displaying, this may
   // be a synthesized string containing the address and localized type name
   // if the device has no obtained name.
-  virtual string16 GetName() const;
+  virtual base::string16 GetName() const;
 
   // Returns the type of the device, limited to those we support or are
   // aware of, by decoding the bluetooth class information. The returned
@@ -369,7 +369,7 @@
  private:
   // Returns a localized string containing the device's bluetooth address and
   // a device type for display when |name_| is empty.
-  string16 GetAddressWithLocalizedDeviceTypeName() const;
+  base::string16 GetAddressWithLocalizedDeviceTypeName() const;
 };
 
 }  // namespace device
diff --git a/device/bluetooth/bluetooth_gatt_characteristic.cc b/device/bluetooth/bluetooth_gatt_characteristic.cc
new file mode 100644
index 0000000..49fd3b3
--- /dev/null
+++ b/device/bluetooth/bluetooth_gatt_characteristic.cc
@@ -0,0 +1,27 @@
+// 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.
+
+#include "device/bluetooth/bluetooth_gatt_characteristic.h"
+
+#include "base/logging.h"
+
+namespace device {
+
+BluetoothGattCharacteristic::BluetoothGattCharacteristic() {
+}
+
+BluetoothGattCharacteristic::~BluetoothGattCharacteristic() {
+}
+
+// static
+BluetoothGattCharacteristic* BluetoothGattCharacteristic::Create(
+    const bluetooth_utils::UUID& uuid,
+    const std::vector<uint8>& value,
+    Properties properties,
+    Permissions permissions) {
+  LOG(ERROR) << "Creating local GATT characteristics currently not supported.";
+  return NULL;
+}
+
+}  // namespace device
diff --git a/device/bluetooth/bluetooth_gatt_characteristic.h b/device/bluetooth/bluetooth_gatt_characteristic.h
new file mode 100644
index 0000000..00f7a88
--- /dev/null
+++ b/device/bluetooth/bluetooth_gatt_characteristic.h
@@ -0,0 +1,195 @@
+// 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 DEVICE_BLUETOOTH_GATT_CHARACTERISTIC_H_
+#define DEVICE_BLUETOOTH_GATT_CHARACTERISTIC_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "device/bluetooth/bluetooth_utils.h"
+
+namespace device {
+
+class BluetoothGattDescriptor;
+class BluetoothGattService;
+
+// BluetoothGattCharacteristic represents a local or remote GATT characteristic.
+// A GATT characteristic is a basic data element used to construct a GATT
+// service. Hence, instances of a BluetoothGattCharacteristic are associated
+// with a BluetoothGattService. There are two ways in which this class is used:
+//
+//   1. To represent GATT characteristics that belong to a service hosted by a
+//      a remote device. In this case the characteristic will be constructed by
+//      the subsystem.
+//   2. To represent GATT characteristics that belong to a locally hosted
+//      service. To achieve this, users can construct instances of
+//      BluetoothGattCharacteristic directly and add it to the desired
+//      BluetoothGattService instance that represents a local service.
+class BluetoothGattCharacteristic {
+ public:
+  // Values representing the possible properties of a characteristic, which
+  // define how the characteristic can be used. Each of these properties serve
+  // a role as defined in the Bluetooth Specification.
+  // |kPropertyExtendedProperties| is a special property that, if present,
+  // indicates that there is a characteristic descriptor (namely the
+  // "Characteristic Extended Properties Descriptor" with UUID 0x2900) that
+  // contains additional properties pertaining to the characteristic.
+  enum Property {
+    kPropertyNone = 0,
+    kPropertyBroadcast = 1 << 0,
+    kPropertyRead = 1 << 1,
+    kPropertyWriteWithoutResponse = 1 << 2,
+    kPropertyWrite = 1 << 3,
+    kPropertyNotify = 1 << 4,
+    kPropertyIndicate = 1 << 5,
+    kPropertyAuthenticatedSignedWrites = 1 << 6,
+    kPropertyExtendedProperties = 1 << 7
+  };
+  typedef uint32 Properties;
+
+  // Values representing read, write, and encryption permissions for a
+  // characteristic's value. While attribute permissions for all GATT
+  // definitions have been set by the Bluetooth specification, characteristic
+  // value permissions are left up to the higher-level profile.
+  //
+  // Attribute permissions are distinct from the characteristic properties. For
+  // example, a characteristic may have the property |kPropertyRead| to make
+  // clients know that it is possible to read the characteristic value and have
+  // the permission |kPermissionReadEncrypted| to require a secure connection.
+  // It is up to the application to properly specify the permissions and
+  // properties for a local characteristic.
+  enum Permission {
+    kPermissionNone = 0,
+    kPermissionRead = 1 << 0,
+    kPermissionWrite = 1 << 1,
+    kPermissionReadEncrypted = 1 << 2,
+    kPermissionWriteEncrypted = 1 << 3
+  };
+  typedef uint32 Permissions;
+
+  // Interface for observing changes from a BluetoothGattCharacteristic.
+  // Properties of remote characteristics are received asynchonously. The
+  // Observer interface can be used to be notified when the initial values of a
+  // characteristic are received as well as when successive changes occur during
+  // its life cycle.
+  class Observer {
+   public:
+    // Called when the UUID of |characteristic| has changed.
+    virtual void UuidChanged(
+        BluetoothGattCharacteristic* characteristic,
+        const bluetooth_utils::UUID& uuid) {}
+
+    // Called when the current value of |characteristic| has changed.
+    virtual void ValueChanged(
+        BluetoothGattCharacteristic* characteristic,
+        const std::vector<uint8>& value) {}
+
+    // Called when the descriptors that are associated with |characteristic|
+    // have changed.
+    virtual void DescriptorsChanged(
+        BluetoothGattCharacteristic* characteristic,
+        const std::vector<BluetoothGattDescriptor*>& descriptors) {}
+  };
+
+  // The ErrorCallback is used by methods to asynchronously report errors.
+  typedef base::Callback<void(const std::string&)> ErrorCallback;
+
+  // The ValueCallback is used to return the value of a remote characteristic
+  // upon a read request.
+  typedef base::Callback<void(const std::vector<uint8>&)> ValueCallback;
+
+  // Adds and removes observers for events on this GATT characteristic. If
+  // monitoring multiple characteristics, check the |characteristic| parameter
+  // of observer methods to determine which characteristic is issuing the event.
+  virtual void AddObserver(Observer* observer) = 0;
+  virtual void RemoveObserver(Observer* observer) = 0;
+
+  // Constructs a BluetoothGattCharacteristic that can be associated with a
+  // local GATT service when the adapter is in the peripheral role. To
+  // associate the returned characteristic with a service, add it to a local
+  // service by calling BluetoothGattService::AddCharacteristic.
+  //
+  // This method constructs a characteristic with UUID |uuid|, initial cached
+  // value |value|, properties |properties|, and permissions |permissions|.
+  // |value| will be cached and returned for read requests and automatically set
+  // for write requests by default, unless an instance of
+  // BluetoothGattService::Delegate has been provided to the associated
+  // BluetoothGattService instance, in which case the delegate will handle read
+  // and write requests.
+  //
+  // NOTE: Don't explicitly set |kPropertyExtendedProperties| in |properties|.
+  // Instead, create and add a BluetoothGattDescriptor that represents the
+  // "Characteristic Extended Properties" descriptor and this will automatically
+  // set the correspoding bit in the characteristic's properties field. If
+  // |properties| has |kPropertyExtendedProperties| set, it will be ignored.
+  static BluetoothGattCharacteristic* Create(const bluetooth_utils::UUID& uuid,
+                                             const std::vector<uint8>& value,
+                                             Properties properties,
+                                             Permissions permissions);
+
+  // The Bluetooth-specific UUID of the characteristic.
+  virtual const bluetooth_utils::UUID& GetUuid() const = 0;
+
+  // Returns true, if this characteristic is hosted locally. If false, then this
+  // instance represents a remote GATT characteristic.
+  virtual bool IsLocal() const = 0;
+
+  // Returns a pointer to the GATT service this characteristic belongs to.
+  virtual const BluetoothGattService* GetService() const = 0;
+
+  // Returns the list of GATT characteristic descriptors that provide more
+  // information about this characteristic.
+  virtual const std::vector<BluetoothGattDescriptor*>
+      GetDescriptors() const = 0;
+
+  // Adds a characteristic descriptor to the locally hosted characteristic
+  // represented by this instance. This method only makes sense for local
+  // characteristics and won't have an effect if this instance represents a
+  // remote GATT service and will return false. This method takes ownership
+  // of |descriptor|.
+  virtual bool AddDescriptor(BluetoothGattDescriptor* descriptor) = 0;
+
+  // For locally hosted characteristics, updates the characteristic's value.
+  // This will update the value that is visible to remote devices and send out
+  // any notifications and indications that have been configured. This method
+  // can be used in place of, and in conjunction with,
+  // BluetoothGattService::Delegate methods to send updates to remote devices,
+  // or simply to set update the cached value for read requests without having
+  // to implement the delegate methods.
+  //
+  // This method only makes sense for local characteristics and does nothing and
+  // returns false if this instance represents a remote characteristic.
+  virtual bool UpdateValue(const std::vector<uint8>& value) = 0;
+
+  // Sends a read request to a remote characteristic to read its value.
+  // |callback| is called to return the read value on success and
+  // |error_callback| is called for failures.
+  virtual void ReadRemoteCharacteristic(
+      const ValueCallback& callback,
+      const ErrorCallback& error_callback) = 0;
+
+  // Sends a write request to a remote characteristic, to modify the
+  // characteristic's value starting at offset |offset| with the new value
+  // |new_value|. |callback| is called to signal success and |error_callback|
+  // for failures. This method only applies to remote characteristics and will
+  // fail for those that are locally hosted.
+  virtual void WriteRemoteCharacteristic(
+      int offset,
+      const std::vector<uint8>& new_value,
+      const base::Closure& callback,
+      const ErrorCallback& error_callback) = 0;
+
+ protected:
+  BluetoothGattCharacteristic();
+  virtual ~BluetoothGattCharacteristic();
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristic);
+};
+
+}  // namespace device
+
+#endif  // DEVICE_BLUETOOTH_GATT_CHARACTERISTIC_H_
diff --git a/device/bluetooth/bluetooth_gatt_descriptor.cc b/device/bluetooth/bluetooth_gatt_descriptor.cc
new file mode 100644
index 0000000..4746cad
--- /dev/null
+++ b/device/bluetooth/bluetooth_gatt_descriptor.cc
@@ -0,0 +1,41 @@
+// 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.
+
+#include "device/bluetooth/bluetooth_gatt_descriptor.h"
+
+#include "base/logging.h"
+
+namespace device {
+
+using bluetooth_utils::UUID;
+
+const UUID BluetoothGattDescriptor::
+    kCharacteristicExtendedPropertiesUuid("0x2900");
+const UUID BluetoothGattDescriptor::
+    kCharacteristicUserDescriptionUuid("0x2901");
+const UUID BluetoothGattDescriptor::
+    kClientCharacteristicConfigurationUuid("0x2902");
+const UUID BluetoothGattDescriptor::
+    kServerCharacteristicConfigurationUuid("0x2903");
+const UUID BluetoothGattDescriptor::
+    kCharacteristicPresentationFormatUuid("0x2904");
+const UUID BluetoothGattDescriptor::
+    kCharacteristicAggregateFormatUuid("0x2905");
+
+BluetoothGattDescriptor::BluetoothGattDescriptor() {
+}
+
+BluetoothGattDescriptor::~BluetoothGattDescriptor() {
+}
+
+// static
+BluetoothGattDescriptor* BluetoothGattDescriptor::Create(
+    const bluetooth_utils::UUID& uuid,
+    const std::vector<uint8>& value) {
+  LOG(ERROR) << "Creating local GATT characteristic descriptors currently not "
+             << "supported.";
+  return NULL;
+}
+
+}  // namespace device
diff --git a/device/bluetooth/bluetooth_gatt_descriptor.h b/device/bluetooth/bluetooth_gatt_descriptor.h
new file mode 100644
index 0000000..9c0a1d2
--- /dev/null
+++ b/device/bluetooth/bluetooth_gatt_descriptor.h
@@ -0,0 +1,197 @@
+// 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 DEVICE_BLUETOOTH_GATT_DESCRIPTOR_H_
+#define DEVICE_BLUETOOTH_GATT_DESCRIPTOR_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "device/bluetooth/bluetooth_utils.h"
+
+namespace device {
+
+class BluetoothGattCharacteristic;
+
+// BluetoothGattDescriptor represents a local or remote GATT characteristic
+// descriptor. A GATT characteristic descriptor provides further information
+// about a characteristic's value. They can be used to describe the
+// characteristic's features or to control certain behaviors.
+class BluetoothGattDescriptor {
+ public:
+  // The Bluetooth Specification declares several predefined descriptors that
+  // profiles can use. The following are definitions for the list of UUIDs
+  // and descriptions of the characteristic descriptors that they represent.
+  // Possible values for and further information on each descriptor can be found
+  // in Core v4.0, Volume 3, Part G, Section 3.3.3. All of these desciptors are
+  // optional and may not be present for a given characteristic.
+
+  // The "Characteristic Extended Properties" descriptor. This defines
+  // additional "Characteristic Properties" which cannot fit into the allocated
+  // single octet property field of a characteristic. The value is a bit field
+  // and the two predefined bits, as per Bluetooth Core Specification v4.0, are:
+  //
+  //    - Reliable Write: 0x0001
+  //    - Writable Auxiliaries: 0x0002
+  //
+  static const bluetooth_utils::UUID kCharacteristicExtendedPropertiesUuid;
+
+  // The "Characteristic User Description" descriptor defines a UTF-8 string of
+  // variable size that is a user textual description of the associated
+  // characteristic's value. There can be only one instance of this descriptor
+  // per characteristic. This descriptor can be written to if the "Writable
+  // Auxiliaries" bit of the Characteristic Properties (via the "Characteristic
+  // Extended Properties" descriptor) has been set.
+  static const bluetooth_utils::UUID kCharacteristicUserDescriptionUuid;
+
+  // The "Client Characteristic Configuration" descriptor defines how the
+  // characteristic may be configured by a specific client. A server-side
+  // instance of this descriptor exists for each client that has bonded with
+  // the server and the value can be read and written by that client only. As
+  // of Core v4.0, this descriptor is used by clients to set up notifications
+  // and indications from a characteristic. The value is a bit field and the
+  // predefined bits are:
+  //
+  //    - Default: 0x0000
+  //    - Notification: 0x0001
+  //    - Indication: 0x0002
+  //
+  static const bluetooth_utils::UUID kClientCharacteristicConfigurationUuid;
+
+  // The "Server Characteristic Configuration" descriptor defines how the
+  // characteristic may be configured for the server. There is one instance
+  // of this descriptor for all clients and setting the value of this descriptor
+  // affects its configuration for all clients. As of Core v4.0, this descriptor
+  // is used to set up the server to broadcast the characteristic value if
+  // advertising resources are available. The value is a bit field and the
+  // predefined bits are:
+  //
+  //    - Default: 0x0000
+  //    - Broadcast: 0x0001
+  //
+  static const bluetooth_utils::UUID kServerCharacteristicConfigurationUuid;
+
+  // The "Characteristic Presentation Format" declaration defines the format of
+  // the Characteristic Value. The value is composed of 7 octets which are
+  // divided into groups that represent different semantic meanings. For a
+  // detailed description of how the value of this descriptor should be
+  // interpreted, refer to Core v4.0, Volume 3, Part G, Section 3.3.3.5. If more
+  // than one declaration of this descriptor exists for a characteristic, then a
+  // "Characteristic Aggregate Format" descriptor must also exist for that
+  // characteristic.
+  static const bluetooth_utils::UUID kCharacteristicPresentationFormatUuid;
+
+  // The "Characteristic Aggregate Format" descriptor defines the format of an
+  // aggragated characteristic value. In GATT's underlying protocol, ATT, each
+  // attribute is identified by a handle that is unique for the hosting server.
+  // Multiple characteristics can share the same instance(s) of a
+  // "Characteristic Presentation Format" descriptor. The value of the
+  // "Characteristic Aggregate Format" descriptor contains a list of handles
+  // that each refer to a "Characteristic Presentation Format" descriptor that
+  // is used by that characteristic. Hence, exactly one instance of this
+  // descriptor must exist if more than one "Characteristic Presentation Format"
+  // descriptors exist for a characteristic.
+  //
+  // Applications that are using the device::Bluetooth API do not have access to
+  // the underlying handles and shouldn't use this descriptor to determine which
+  // "Characteristic Presentation Format" desciptors belong to a characteristic.
+  // The API will construct a BluetoothGattDescriptor object for each instance
+  // of "Characteristic Presentation Format" descriptor per instance of
+  // BluetoothGattCharacteristic that represents a remote characteristic.
+  // Similarly for local characteristics, implementations DO NOT need to create
+  // an instance of BluetoothGattDescriptor for this descriptor as this will be
+  // handled by the subsystem.
+  static const bluetooth_utils::UUID kCharacteristicAggregateFormatUuid;
+
+  // Interface for observing changes from a BluetoothGattDescriptor.
+  // Properties of remote characteristic desciptors are received asynchonously.
+  // The Observer interface can be used to be notified when the initial values
+  // of a characteristic descriptor are received as well as when successive
+  // changes occur during its life cycle.
+  class Observer {
+   public:
+    // Called when the UUID of |descriptor| has changed.
+    virtual void UuidChanged(
+        BluetoothGattDescriptor* descriptor,
+        const bluetooth_utils::UUID& uuid) {}
+
+    // Called when the current value of |descriptor| has changed.
+    virtual void ValueChanged(
+        BluetoothGattDescriptor* descriptor,
+        const std::vector<uint8>& value) {}
+  };
+
+  // The ErrorCallback is used by methods to asynchronously report errors.
+  typedef base::Callback<void(const std::string&)> ErrorCallback;
+
+  // The ValueCallback is used to return the value of a remote characteristic
+  // descriptor upon a read request.
+  typedef base::Callback<void(const std::vector<uint8>&)> ValueCallback;
+
+  // Adds and removes observers for events on this GATT characteristic
+  // descriptor. If monitoring multiple descriptors, check the |descriptor|
+  // parameter of observer methods to determine which characteristic is issuing
+  // the event.
+  virtual void AddObserver(Observer* observer) = 0;
+  virtual void RemoveObserver(Observer* observer) = 0;
+
+  // Constructs a BluetoothGattDescriptor that can be associated with a local
+  // GATT characteristic when the adapter is in the peripheral role. To
+  // associate the returned descriptor with a characteristic, add it to a local
+  // characteristic by calling BluetoothGattCharacteristic::AddDescriptor.
+  //
+  // This method constructs a characteristic descriptor with UUID |uuid| and the
+  // initial cached value |value|. |value| will be cached and returned for read
+  // requests and automatically modified for write requests by default, unless
+  // an instance of BluetoothGattService::Delegate has been provided to the
+  // associated BluetoothGattService instance, in which case the delegate will
+  // handle the read and write requests.
+  //
+  // Currently, only custom UUIDs, |kCharacteristicDescriptionUuid|, and
+  // |kCharacteristicPresentationFormat| are supported for locally hosted
+  // descriptors. This method will return NULL if |uuid| is any one of the
+  // unsupported predefined descriptor UUIDs.
+  static BluetoothGattDescriptor* Create(const bluetooth_utils::UUID& uuid,
+                                         const std::vector<uint8>& value);
+
+  // The Bluetooth-specific UUID of the characteristic descriptor.
+  virtual const bluetooth_utils::UUID& GetUuid() const = 0;
+
+  // Returns true, if this characteristic descriptor is hosted locally. If
+  // false, then this instance represents a remote descriptor.
+  virtual bool IsLocal() const = 0;
+
+  // Returns a pointer to the GATT characteristic that this characteristic
+  // descriptor belongs to.
+  virtual const BluetoothGattCharacteristic* GetCharacteristic() const = 0;
+
+  // Sends a read request to a remote characteristic descriptor to read its
+  // value. |callback| is called to return the read value on success and
+  // |error_callback| is called for failures.
+  virtual void ReadRemoteDescriptor(const ValueCallback& callback,
+                                    const ErrorCallback& error_callback) = 0;
+
+  // Sends a write request to a remote characteristic descriptor, to modify the
+  // value of the descriptor starting at offset |offset| with the new value
+  // |new_value|. |callback| is called to signal success and |error_callback|
+  // for failures. This method only applies to remote descriptors and will fail
+  // for those that are locally hosted.
+  virtual void WriteRemoteDescriptor(
+      int offset,
+      const std::vector<uint8>& new_value,
+      const base::Closure& callback,
+      const ErrorCallback& error_callback) = 0;
+
+ protected:
+  BluetoothGattDescriptor();
+  virtual ~BluetoothGattDescriptor();
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptor);
+};
+
+}  // namespace device
+
+#endif  // DEVICE_BLUETOOTH_GATT_DESCRIPTOR_H_
diff --git a/device/bluetooth/bluetooth_gatt_service.cc b/device/bluetooth/bluetooth_gatt_service.cc
new file mode 100644
index 0000000..dccb06a
--- /dev/null
+++ b/device/bluetooth/bluetooth_gatt_service.cc
@@ -0,0 +1,26 @@
+// 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.
+
+#include "device/bluetooth/bluetooth_gatt_service.h"
+
+#include "base/logging.h"
+
+namespace device {
+
+BluetoothGattService::BluetoothGattService() {
+}
+
+BluetoothGattService::~BluetoothGattService() {
+}
+
+// static
+BluetoothGattService* BluetoothGattService::Create(
+    const bluetooth_utils::UUID& uuid,
+    bool is_primary,
+    Delegate* delegate) {
+  LOG(ERROR) << "Creating local GATT services currently not supported.";
+  return NULL;
+}
+
+}  // namespace device
diff --git a/device/bluetooth/bluetooth_gatt_service.h b/device/bluetooth/bluetooth_gatt_service.h
new file mode 100644
index 0000000..963fdd5
--- /dev/null
+++ b/device/bluetooth/bluetooth_gatt_service.h
@@ -0,0 +1,226 @@
+// 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 DEVICE_BLUETOOTH_GATT_SERVICE_H_
+#define DEVICE_BLUETOOTH_GATT_SERVICE_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "device/bluetooth/bluetooth_utils.h"
+
+namespace device {
+
+class BluetoothGattCharacteristic;
+class BluetoothGattDescriptor;
+
+// BluetoothGattService represents a local or remote GATT service. A GATT
+// service is hosted by a peripheral and represents a collection of data in
+// the form of GATT characteristics and a set of included GATT services if this
+// service is what is called "a primary service".
+//
+// Instances of the BluetoothGattService class are used for two functions:
+//   1. To represent GATT attribute hierarchies that have been received from a
+//      remote Bluetooth GATT peripheral. Such BluetoothGattService instances
+//      are constructed and owned by a BluetoothDevice.
+//
+//   2. To represent a locally hosted GATT attribute hierarchy when the local
+//      adapter is used in the "peripheral" role. Such instances are meant to be
+//      constructed directly and registered. Once registered, a GATT attribute
+//      hierarchy will be visible to remote devices in the "central" role.
+class BluetoothGattService {
+ public:
+  // The Delegate class is used to send certain events that need to be handled
+  // when the device is in peripheral mode. The delegate handles read and write
+  // requests that are issued from remote clients.
+  class Delegate {
+   public:
+    // Callbacks used for communicating GATT request responses.
+    typedef base::Callback<void(const std::vector<uint8>)> ValueCallback;
+    typedef base::Closure ErrorCallback;
+
+    // Called when a remote device in the central role requests to read the
+    // value of the characteristic |characteristic| starting at offset |offset|.
+    // This method is only called if the characteristic was specified as
+    // readable and any authentication and authorization challanges were
+    // satisfied by the remote device.
+    //
+    // To respond to the request with success and return the requested value,
+    // the delegate must invoke |callback| with the value. Doing so will
+    // automatically update the value property of |characteristic|. To respond
+    // to the request with failure (e.g. if an invalid offset was given),
+    // delegates must invoke |error_callback|. If neither callback parameter is
+    // invoked, the request will time out and result in an error. Therefore,
+    // delegates MUST invoke either |callback| or |error_callback|.
+    virtual void OnCharacteristicReadRequest(
+        const BluetoothGattService* service,
+        const BluetoothGattCharacteristic* characteristic,
+        int offset,
+        const ValueCallback& callback,
+        const ErrorCallback& error_callback) = 0;
+
+    // Called when a remote device in the central role requests to write the
+    // value of the characteristic |characteristic| starting at offset |offset|.
+    // This method is only called if the characteristic was specified as
+    // writeable and any authentication and authorization challanges were
+    // satisfied by the remote device.
+    //
+    // To respond to the request with success the delegate must invoke
+    // |callback| with the new value of the characteristic. Doing so will
+    // automatically update the value property of |characteristic|. To respond
+    // to the request with failure (e.g. if an invalid offset was given),
+    // delegates must invoke |error_callback|. If neither callback parameter is
+    // invoked, the request will time out and result in an error. Therefore,
+    // delegates MUST invoke either |callback| or |error_callback|.
+    virtual void OnCharacteristicWriteRequest(
+        const BluetoothGattService* service,
+        const BluetoothGattCharacteristic* characteristic,
+        const std::vector<uint8>& value,
+        int offset,
+        const ValueCallback& callback,
+        const ErrorCallback& error_callback) = 0;
+
+    // Called when a remote device in the central role requests to read the
+    // value of the descriptor |descriptor| starting at offset |offset|.
+    // This method is only called if the characteristic was specified as
+    // readable and any authentication and authorization challanges were
+    // satisfied by the remote device.
+    //
+    // To respond to the request with success and return the requested value,
+    // the delegate must invoke |callback| with the value. Doing so will
+    // automatically update the value property of |descriptor|. To respond
+    // to the request with failure (e.g. if an invalid offset was given),
+    // delegates must invoke |error_callback|. If neither callback parameter is
+    // invoked, the request will time out and result in an error. Therefore,
+    // delegates MUST invoke either |callback| or |error_callback|.
+    virtual void OnDescriptorReadRequest(
+        const BluetoothGattService* service,
+        const BluetoothGattDescriptor* descriptor,
+        int offset,
+        const ValueCallback& callback,
+        const ErrorCallback& error_callback) = 0;
+
+    // Called when a remote device in the central role requests to write the
+    // value of the descriptor |descriptor| starting at offset |offset|.
+    // This method is only called if the characteristic was specified as
+    // writeable and any authentication and authorization challanges were
+    // satisfied by the remote device.
+    //
+    // To respond to the request with success the delegate must invoke
+    // |callback| with the new value of the descriptor. Doing so will
+    // automatically update the value property of |descriptor|. To respond
+    // to the request with failure (e.g. if an invalid offset was given),
+    // delegates must invoke |error_callback|. If neither callback parameter is
+    // invoked, the request will time out and result in an error. Therefore,
+    // delegates MUST invoke either |callback| or |error_callback|.
+    virtual void OnDescriptorWriteRequest(
+        const BluetoothGattService* service,
+        const BluetoothGattDescriptor* descriptor,
+        const std::vector<uint8>& value,
+        int offset,
+        const ValueCallback& callback,
+        const ErrorCallback& error_callback) = 0;
+  };
+
+  // Interface for observing changes from a BluetoothGattService. Properties
+  // of remote services are received asynchronously. The Observer interface can
+  // be used to be notified when the initial values of a service are received
+  // as well as when successive changes occur during its life cycle.
+  class Observer {
+   public:
+    // Called when the UUID of |service| have changed.
+    virtual void UuidChanged(
+        BluetoothGattService* service,
+        const bluetooth_utils::UUID& uuid) {}
+
+    // Called when the services included by |service| have changed.
+    virtual void IncludedServicesChanged(
+        BluetoothGattService* service,
+        const std::vector<BluetoothGattService*>& included_services) {}
+
+    // Called when the characteristics that belong to |service| have changed.
+    virtual void CharacteristicsChanged(
+        BluetoothGattService* service,
+        const std::vector<BluetoothGattCharacteristic*>& characteristics) {}
+  };
+
+  // The ErrorCallback is used by methods to asynchronously report errors.
+  typedef base::Callback<void(const std::string&)> ErrorCallback;
+
+  // Constructs a BluetoothGattService that can be locally hosted when the local
+  // adapter is in the peripheral role. The resulting object can then be made
+  // available by calling the "Register" method. This method constructs a
+  // service with UUID |uuid|. Whether the constructed service is primary or
+  // secondary is determined by |is_primary|. |delegate| is used to send certain
+  // peripheral role events. If |delegate| is NULL, then this service will
+  // employ a default behavior when responding to read and write requests based
+  // on the cached value of its characteristics and descriptors at a given time.
+  static BluetoothGattService* Create(const bluetooth_utils::UUID& uuid,
+                                      bool is_primary,
+                                      Delegate* delegate);
+
+  // The Bluetooth-specific UUID of the service.
+  virtual const bluetooth_utils::UUID& GetUuid() const = 0;
+
+  // Returns true, if this service hosted locally. If false, then this service
+  // represents a remote GATT service.
+  virtual bool IsLocal() const = 0;
+
+  // Indicates whether the type of this service is primary or secondary. A
+  // primary service describes the primary function of the peripheral that
+  // hosts it, while a secondary service only makes sense in the presence of a
+  // primary service. A primary service may include other primary or secondary
+  // services.
+  virtual bool IsPrimary() const = 0;
+
+  // List of characteristics that belong to this service.
+  virtual const std::vector<BluetoothGattCharacteristic*>&
+      GetCharacteristics() const = 0;
+
+  // List of GATT services that are included by this service.
+  virtual const std::vector<BluetoothGattService*>&
+      GetIncludedServices() const = 0;
+
+  // Adds and removes observers for events on this GATT service. If monitoring
+  // multiple services, check the |service| parameter of observer methods to
+  // determine which service is issuing the event.
+  virtual void AddObserver(Observer* observer) = 0;
+  virtual void RemoveObserver(Observer* observer) = 0;
+
+  // Adds characteristics and included services to the local attribute hierarchy
+  // represented by this service. These methods only make sense for local
+  // services and won't have an effect if this instance represents a remote
+  // GATT service and will return false. While ownership of added
+  // characteristics are taken over by the service, ownership of an included
+  // service is not taken.
+  virtual bool AddCharacteristic(
+      BluetoothGattCharacteristic* characteristic) = 0;
+  virtual bool AddService(BluetoothGattService* service) = 0;
+
+  // Registers this GATT service. Calling Register will make this service and
+  // all of its associated attributes available on the local adapters GATT
+  // database and the service UUID will be advertised to nearby devices if the
+  // local adapter is discoverable. Call Unregister to make this service no
+  // longer available.
+  //
+  // These methods only make sense for services that are local and will hence
+  // fail if this instance represents a remote GATT service. |callback| is
+  // called to denote success and |error_callback| to denote failure.
+  virtual void Register(const base::Closure& callback,
+                        const ErrorCallback& error_callback) = 0;
+  virtual void Unregister(const base::Closure& callback,
+                          const ErrorCallback& error_callback) = 0;
+
+ protected:
+  BluetoothGattService();
+  virtual ~BluetoothGattService();
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(BluetoothGattService);
+};
+
+}  // namespace device
+
+#endif  // DEVICE_BLUETOOTH_GATT_SERVICE_H_
diff --git a/device/bluetooth/bluetooth_profile_chromeos_unittest.cc b/device/bluetooth/bluetooth_profile_chromeos_unittest.cc
index 1792cda..dd7c945 100644
--- a/device/bluetooth/bluetooth_profile_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_profile_chromeos_unittest.cc
@@ -31,8 +31,7 @@
 class BluetoothProfileChromeOSTest : public testing::Test {
  public:
   BluetoothProfileChromeOSTest()
-      : message_loop_(base::MessageLoop::TYPE_IO),
-        callback_count_(0),
+      : callback_count_(0),
         error_callback_count_(0),
         profile_callback_count_(0),
         connection_callback_count_(0),
@@ -102,7 +101,7 @@
   }
 
  protected:
-  base::MessageLoop message_loop_;
+  base::MessageLoopForIO message_loop_;
 
   FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client_;
   scoped_refptr<BluetoothAdapter> adapter_;
diff --git a/device/bluetooth/bluetooth_utils.cc b/device/bluetooth/bluetooth_utils.cc
index b1f9f78..df0c875 100644
--- a/device/bluetooth/bluetooth_utils.cc
+++ b/device/bluetooth/bluetooth_utils.cc
@@ -10,49 +10,103 @@
 #include "base/logging.h"
 #include "base/strings/string_util.h"
 
-namespace {
-static const char* kCommonUuidPostfix = "-0000-1000-8000-00805f9b34fb";
-static const char* kCommonUuidPrefix = "0000";
-static const int kUuidSize = 36;
-}  // namespace
-
 namespace device {
 namespace bluetooth_utils {
 
-std::string CanonicalUuid(std::string uuid) {
+namespace {
+
+const char* kCommonUuidPostfix = "-0000-1000-8000-00805f9b34fb";
+const char* kCommonUuidPrefix = "0000";
+const int kUuidSize = 36;
+
+// Returns the canonical, 128-bit canonical, and the format of the UUID
+// in |canonical|, |canonical_128|, and |format| based on |uuid|.
+void GetCanonicalUuid(std::string uuid,
+                      std::string* canonical,
+                      std::string* canonical_128,
+                      UUID::Format* format) {
+  // Initialize the values for the failure case.
+  canonical->clear();
+  canonical_128->clear();
+  *format = UUID::kFormatInvalid;
+
   if (uuid.empty())
-    return std::string();
+    return;
 
   if (uuid.size() < 11 && uuid.find("0x") == 0)
     uuid = uuid.substr(2);
 
   if (!(uuid.size() == 4 || uuid.size() == 8 || uuid.size() == 36))
-    return std::string();
+    return;
 
   if (uuid.size() == 4 || uuid.size() == 8) {
     for (size_t i = 0; i < uuid.size(); ++i) {
       if (!IsHexDigit(uuid[i]))
-        return std::string();
+        return;
     }
-
-    if (uuid.size() == 4)
-      return kCommonUuidPrefix + uuid + kCommonUuidPostfix;
-
-    return uuid + kCommonUuidPostfix;
+    if (uuid.size() == 4) {
+      canonical->assign(uuid);
+      canonical_128->assign(kCommonUuidPrefix + uuid + kCommonUuidPostfix);
+      *format = UUID::kFormat16Bit;
+      return;
+    }
+    canonical->assign(uuid);
+    canonical_128->assign(uuid + kCommonUuidPostfix);
+    *format = UUID::kFormat32Bit;
+    return;
   }
 
-  std::string uuid_result(uuid);
   for (int i = 0; i < kUuidSize; ++i) {
     if (i == 8 || i == 13 || i == 18 || i == 23) {
       if (uuid[i] != '-')
-        return std::string();
+        return;
     } else {
       if (!IsHexDigit(uuid[i]))
-        return std::string();
-      uuid_result[i] = tolower(uuid[i]);
+        return;
+      uuid[i] = tolower(uuid[i]);
     }
   }
-  return uuid_result;
+
+  canonical->assign(uuid);
+  canonical_128->assign(uuid);
+  *format = UUID::kFormat128Bit;
+}
+
+}  // namespace
+
+
+UUID::UUID(const std::string& uuid) {
+  GetCanonicalUuid(uuid, &value_, &canonical_value_, &format_);
+}
+
+UUID::UUID() : format_(kFormatInvalid) {
+}
+
+UUID::~UUID() {
+}
+
+bool UUID::IsValid() const {
+  return format_ != kFormatInvalid;
+}
+
+bool UUID::operator<(const UUID& uuid) const {
+  return canonical_value_ < uuid.canonical_value_;
+}
+
+bool UUID::operator==(const UUID& uuid) const {
+  return canonical_value_ == uuid.canonical_value_;
+}
+
+bool UUID::operator!=(const UUID& uuid) const {
+  return canonical_value_ != uuid.canonical_value_;
+}
+
+std::string CanonicalUuid(std::string uuid) {
+  std::string value;
+  std::string canonical_value;
+  UUID::Format format;
+  GetCanonicalUuid(uuid, &value, &canonical_value, &format);
+  return canonical_value;
 }
 
 }  // namespace bluetooth_utils
diff --git a/device/bluetooth/bluetooth_utils.h b/device/bluetooth/bluetooth_utils.h
index 0995160..44b52b1 100644
--- a/device/bluetooth/bluetooth_utils.h
+++ b/device/bluetooth/bluetooth_utils.h
@@ -12,6 +12,84 @@
 namespace device {
 namespace bluetooth_utils {
 
+// Opaque wrapper around a Bluetooth UUID. Instances of UUID represent the
+// 128-bit universally unique identifiers (UUIDs) of profiles and attributes
+// used in Bluetooth based communication, such as a peripheral's services,
+// characteristics, and characteristic descriptors. An instance are
+// constructed using a string representing 16, 32, or 128 bit UUID formats.
+class UUID {
+ public:
+  // Possible representation formats used during construction.
+  enum Format {
+    kFormatInvalid,
+    kFormat16Bit,
+    kFormat32Bit,
+    kFormat128Bit
+  };
+
+  // Single argument constructor. |uuid| can be a 16, 32, or 128 bit UUID
+  // represented as a 4, 8, or 36 character string with the following
+  // formats:
+  //   XXXX
+  //   0xXXXX
+  //   XXXXXXXX
+  //   0xXXXXXXXX
+  //   XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
+  //
+  // 16 and 32 bit UUIDs will be internally converted to a 128 bit UUID using
+  // the base UUID defined in the Bluetooth specification, hence custom UUIDs
+  // should be provided in the 128-bit format. If |uuid| is in an unsupported
+  // format, the result might be invalid. Use IsValid to check for validity
+  // after construction.
+  explicit UUID(const std::string& uuid);
+  ~UUID();
+
+  // Returns true, if the UUID is in a valid canonical format.
+  bool IsValid() const;
+
+  // Returns the representation format of the UUID. This reflects the format
+  // that was provided during construction.
+  Format format() const { return format_; }
+
+  // Returns the value of the UUID as a string. The representation format is
+  // based on what was passed in during construction. For the supported sizes,
+  // this representation can have the following formats:
+  //   - 16 bit:  XXXX
+  //   - 32 bit:  XXXXXXXX
+  //   - 128 bit: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
+  // where X is a lowercase hex digit.
+  const std::string& value() const { return value_; }
+
+  // Returns the underlying 128-bit value as a string in the following format:
+  //   XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
+  // where X is a lowercase hex digit.
+  const std::string& canonical_value() const { return canonical_value_; }
+
+  // Permit sufficient comparison to allow a UUID to be used as a key in a
+  // std::map.
+  bool operator<(const UUID& uuid) const;
+
+  // Equality operators.
+  bool operator==(const UUID& uuid) const;
+  bool operator!=(const UUID& uuid) const;
+
+ private:
+  UUID();
+
+  // String representation of the UUID that was used during construction. For
+  // the supported sizes, this representation can have the following formats:
+  //   - 16 bit:  XXXX
+  //   - 32 bit:  XXXXXXXX
+  //   - 128 bit: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
+  Format format_;
+  std::string value_;
+
+  // The 128-bit string representation of the UUID.
+  std::string canonical_value_;
+};
+
+// DEPRECATED. Use bluetooth_utils::UUID instead.
+//
 // Takes a 4, 8 or 36 character UUID, validates it and returns it in 36
 // character format with all hex digits lower case.  If |uuid| is invalid, the
 // empty string is returned.
diff --git a/device/bluetooth/bluetooth_utils_unittest.cc b/device/bluetooth/bluetooth_utils_unittest.cc
index 46d5f34..07c63b5 100644
--- a/device/bluetooth/bluetooth_utils_unittest.cc
+++ b/device/bluetooth/bluetooth_utils_unittest.cc
@@ -7,47 +7,100 @@
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace device {
+namespace bluetooth_utils {
 
 TEST(BluetoothUtilsTest, CanonicalUuid) {
   // Does nothing for an already canonical UUID
   EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
-      bluetooth_utils::CanonicalUuid("00001101-0000-1000-8000-00805f9b34fb"));
+      CanonicalUuid("00001101-0000-1000-8000-00805f9b34fb"));
 
   // Rejects misformatted
-  EXPECT_EQ("", bluetooth_utils::CanonicalUuid("1101a"));
-  EXPECT_EQ("", bluetooth_utils::CanonicalUuid("Z101"));
-  EXPECT_EQ("", bluetooth_utils::CanonicalUuid("0000-1101"));
-  EXPECT_EQ("", bluetooth_utils::CanonicalUuid("0000Z101"));
-  EXPECT_EQ("",
-      bluetooth_utils::CanonicalUuid("0001101-0000-1000-8000-00805f9b34fb"));
-  EXPECT_EQ("",
-      bluetooth_utils::CanonicalUuid("Z0001101-0000-1000-8000-00805f9b34fb"));
-  EXPECT_EQ("",
-      bluetooth_utils::CanonicalUuid("00001101 0000-1000-8000-00805f9b34fb"));
-  EXPECT_EQ("",
-      bluetooth_utils::CanonicalUuid("00001101-0000:1000-8000-00805f9b34fb"));
-  EXPECT_EQ("",
-      bluetooth_utils::CanonicalUuid("00001101-0000-1000;8000-00805f9b34fb"));
-  EXPECT_EQ("",
-      bluetooth_utils::CanonicalUuid("00001101-0000-1000-8000000805f9b34fb"));
+  EXPECT_EQ("", CanonicalUuid("1101a"));
+  EXPECT_EQ("", CanonicalUuid("Z101"));
+  EXPECT_EQ("", CanonicalUuid("0000-1101"));
+  EXPECT_EQ("", CanonicalUuid("0000Z101"));
+  EXPECT_EQ("", CanonicalUuid("0001101-0000-1000-8000-00805f9b34fb"));
+  EXPECT_EQ("", CanonicalUuid("Z0001101-0000-1000-8000-00805f9b34fb"));
+  EXPECT_EQ("", CanonicalUuid("00001101 0000-1000-8000-00805f9b34fb"));
+  EXPECT_EQ("", CanonicalUuid("00001101-0000:1000-8000-00805f9b34fb"));
+  EXPECT_EQ("", CanonicalUuid("00001101-0000-1000;8000-00805f9b34fb"));
+  EXPECT_EQ("", CanonicalUuid("00001101-0000-1000-8000000805f9b34fb"));
 
   // Lower case
   EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
-      bluetooth_utils::CanonicalUuid("00001101-0000-1000-8000-00805F9B34FB"));
+      CanonicalUuid("00001101-0000-1000-8000-00805F9B34FB"));
 
   // Short to full
   EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
-      bluetooth_utils::CanonicalUuid("1101"));
+      CanonicalUuid("1101"));
   EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
-      bluetooth_utils::CanonicalUuid("0x1101"));
+      CanonicalUuid("0x1101"));
   EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
-      bluetooth_utils::CanonicalUuid("00001101"));
+      CanonicalUuid("00001101"));
   EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
-      bluetooth_utils::CanonicalUuid("0x00001101"));
+      CanonicalUuid("0x00001101"));
 
   // No 0x prefix on 36 character
-  EXPECT_EQ("",
-      bluetooth_utils::CanonicalUuid("0x00001101-0000-1000-8000-00805f9b34fb"));
+  EXPECT_EQ("", CanonicalUuid("0x00001101-0000-1000-8000-00805f9b34fb"));
 }
 
+TEST(BluetoothUtilsTest, UUID) {
+  const char kValid128Bit0[] = "12345678-1234-5678-9abc-def123456789";
+  const char kValid128Bit1[] = "00001101-0000-1000-8000-00805f9b34fb";
+  const char kInvalid36Char[] = "1234567-1234-5678-9abc-def123456789";
+  const char kInvalid4Char[] = "Z101";
+  const char kValid16Bit[] = "0x1101";
+  const char kValid32Bit[] = "00001101";
+
+  // Valid 128-bit custom UUID.
+  UUID uuid0(kValid128Bit0);
+  EXPECT_TRUE(uuid0.IsValid());
+  EXPECT_EQ(UUID::kFormat128Bit, uuid0.format());
+  EXPECT_EQ(uuid0.value(), uuid0.canonical_value());
+
+  // Valid 128-bit UUID.
+  UUID uuid1(kValid128Bit1);
+  EXPECT_TRUE(uuid1.IsValid());
+  EXPECT_EQ(UUID::kFormat128Bit, uuid1.format());
+  EXPECT_EQ(uuid1.value(), uuid1.canonical_value());
+
+  EXPECT_NE(uuid0, uuid1);
+
+  // Invalid 128-bit UUID.
+  UUID uuid2(kInvalid36Char);
+  EXPECT_FALSE(uuid2.IsValid());
+  EXPECT_EQ(UUID::kFormatInvalid, uuid2.format());
+  EXPECT_TRUE(uuid2.value().empty());
+  EXPECT_TRUE(uuid2.canonical_value().empty());
+
+  // Invalid 16-bit UUID.
+  UUID uuid3(kInvalid4Char);
+  EXPECT_FALSE(uuid3.IsValid());
+  EXPECT_EQ(UUID::kFormatInvalid, uuid3.format());
+  EXPECT_TRUE(uuid3.value().empty());
+  EXPECT_TRUE(uuid3.canonical_value().empty());
+
+  // Valid 16-bit UUID.
+  UUID uuid4(kValid16Bit);
+  EXPECT_TRUE(uuid4.IsValid());
+  EXPECT_EQ(UUID::kFormat16Bit, uuid4.format());
+  EXPECT_NE(uuid4.value(), uuid4.canonical_value());
+  EXPECT_EQ("1101", uuid4.value());
+  EXPECT_EQ(kValid128Bit1, uuid4.canonical_value());
+
+  // Valid 32-bit UUID.
+  UUID uuid5(kValid32Bit);
+  EXPECT_TRUE(uuid5.IsValid());
+  EXPECT_EQ(UUID::kFormat32Bit, uuid5.format());
+  EXPECT_NE(uuid5.value(), uuid5.canonical_value());
+  EXPECT_EQ("00001101", uuid5.value());
+  EXPECT_EQ(kValid128Bit1, uuid5.canonical_value());
+
+  // uuid4, uuid5, and uuid1 are equivalent.
+  EXPECT_EQ(uuid4, uuid5);
+  EXPECT_EQ(uuid1, uuid4);
+  EXPECT_EQ(uuid1, uuid5);
+}
+
+}  // namespace bluetooth_utils
 }  // namespace device
diff --git a/device/bluetooth/test/mock_bluetooth_adapter.h b/device/bluetooth/test/mock_bluetooth_adapter.h
index d2c9878..0266f03 100644
--- a/device/bluetooth/test/mock_bluetooth_adapter.h
+++ b/device/bluetooth/test/mock_bluetooth_adapter.h
@@ -35,11 +35,20 @@
   MOCK_METHOD1(RemoveObserver, void(BluetoothAdapter::Observer*));
   MOCK_CONST_METHOD0(GetAddress, std::string());
   MOCK_CONST_METHOD0(GetName, std::string());
+  MOCK_METHOD3(SetName,
+               void(const std::string& name,
+                    const base::Closure& callback,
+                    const ErrorCallback& error_callback));
   MOCK_CONST_METHOD0(IsInitialized, bool());
   MOCK_CONST_METHOD0(IsPresent, bool());
   MOCK_CONST_METHOD0(IsPowered, bool());
   MOCK_METHOD3(SetPowered,
-               void(bool discovering,
+               void(bool powered,
+                    const base::Closure& callback,
+                    const ErrorCallback& error_callback));
+  MOCK_CONST_METHOD0(IsDiscoverable, bool());
+  MOCK_METHOD3(SetDiscoverable,
+               void(bool discoverable,
                     const base::Closure& callback,
                     const ErrorCallback& error_callback));
   MOCK_CONST_METHOD0(IsDiscovering, bool());
diff --git a/device/bluetooth/test/mock_bluetooth_device.cc b/device/bluetooth/test/mock_bluetooth_device.cc
index b4c6cfe..c1fe56f 100644
--- a/device/bluetooth/test/mock_bluetooth_device.cc
+++ b/device/bluetooth/test/mock_bluetooth_device.cc
@@ -33,7 +33,7 @@
   ON_CALL(*this, IsConnecting())
       .WillByDefault(testing::Return(false));
   ON_CALL(*this, GetName())
-      .WillByDefault(testing::Return(UTF8ToUTF16(name_)));
+      .WillByDefault(testing::Return(base::UTF8ToUTF16(name_)));
   ON_CALL(*this, ExpectingPinCode())
       .WillByDefault(testing::Return(false));
   ON_CALL(*this, ExpectingPasskey())
diff --git a/device/bluetooth/test/mock_bluetooth_device.h b/device/bluetooth/test/mock_bluetooth_device.h
index 6020579..de2907d 100644
--- a/device/bluetooth/test/mock_bluetooth_device.h
+++ b/device/bluetooth/test/mock_bluetooth_device.h
@@ -32,7 +32,7 @@
   MOCK_CONST_METHOD0(GetVendorID, uint16());
   MOCK_CONST_METHOD0(GetProductID, uint16());
   MOCK_CONST_METHOD0(GetDeviceID, uint16());
-  MOCK_CONST_METHOD0(GetName, string16());
+  MOCK_CONST_METHOD0(GetName, base::string16());
   MOCK_CONST_METHOD0(GetDeviceType, BluetoothDevice::DeviceType());
   MOCK_CONST_METHOD0(IsPaired, bool());
   MOCK_CONST_METHOD0(IsConnected, bool());