| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/serial/serial_connection.h" | 5 #include "chrome/browser/extensions/api/serial/serial_connection.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "chrome/browser/extensions/api/api_resource_manager.h" | 13 #include "chrome/browser/extensions/api/api_resource_manager.h" |
| 14 #include "chrome/common/extensions/api/serial.h" | 14 #include "chrome/common/extensions/api/serial.h" |
| 15 | 15 |
| 16 namespace extensions { | 16 namespace extensions { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const int kDefaultBufferSize = 4096; | 20 const int kDefaultBufferSize = 4096; |
| 21 | 21 |
| 22 } | 22 } |
| 23 | 23 |
| 24 static base::LazyInstance<ProfileKeyedAPIFactory< | 24 static base::LazyInstance< |
| 25 ApiResourceManager<SerialConnection> > > | 25 BrowserContextKeyedAPIFactory<ApiResourceManager<SerialConnection> > > |
| 26 g_factory = LAZY_INSTANCE_INITIALIZER; | 26 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 27 | 27 |
| 28 // static | 28 // static |
| 29 template <> | 29 template <> |
| 30 ProfileKeyedAPIFactory<ApiResourceManager<SerialConnection> >* | 30 BrowserContextKeyedAPIFactory<ApiResourceManager<SerialConnection> >* |
| 31 ApiResourceManager<SerialConnection>::GetFactoryInstance() { | 31 ApiResourceManager<SerialConnection>::GetFactoryInstance() { |
| 32 return g_factory.Pointer(); | 32 return g_factory.Pointer(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 SerialConnection::SerialConnection(const std::string& port, | 35 SerialConnection::SerialConnection(const std::string& port, |
| 36 const std::string& owner_extension_id) | 36 const std::string& owner_extension_id) |
| 37 : ApiResource(owner_extension_id), | 37 : ApiResource(owner_extension_id), |
| 38 port_(port), | 38 port_(port), |
| 39 file_(base::kInvalidPlatformFileValue), | 39 file_(base::kInvalidPlatformFileValue), |
| 40 persistent_(false), | 40 persistent_(false), |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 delay_); | 257 delay_); |
| 258 } | 258 } |
| 259 | 259 |
| 260 SerialConnection::TimeoutTask::~TimeoutTask() {} | 260 SerialConnection::TimeoutTask::~TimeoutTask() {} |
| 261 | 261 |
| 262 void SerialConnection::TimeoutTask::Run() const { | 262 void SerialConnection::TimeoutTask::Run() const { |
| 263 closure_.Run(); | 263 closure_.Run(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace extensions | 266 } // namespace extensions |
| OLD | NEW |