| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ipc/attachment_broker_privileged.h" | 5 #include "ipc/attachment_broker_privileged.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // On platforms that support attachment brokering, returns a new instance of | 51 // On platforms that support attachment brokering, returns a new instance of |
| 52 // a platform-specific attachment broker. Otherwise returns |nullptr|. | 52 // a platform-specific attachment broker. Otherwise returns |nullptr|. |
| 53 // The caller takes ownership of the newly created instance, and is | 53 // The caller takes ownership of the newly created instance, and is |
| 54 // responsible for ensuring that the attachment broker lives longer than | 54 // responsible for ensuring that the attachment broker lives longer than |
| 55 // every IPC::Channel. The new instance automatically registers itself as the | 55 // every IPC::Channel. The new instance automatically registers itself as the |
| 56 // global attachment broker. | 56 // global attachment broker. |
| 57 std::unique_ptr<AttachmentBrokerPrivileged> CreateBroker() { | 57 std::unique_ptr<AttachmentBrokerPrivileged> CreateBroker() { |
| 58 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 59 return base::WrapUnique(new IPC::AttachmentBrokerPrivilegedWin); | 59 return base::WrapUnique(new IPC::AttachmentBrokerPrivilegedWin); |
| 60 #elif defined(OS_MACOSX) && !defined(OS_IOS) | 60 #elif defined(OS_MACOSX) && !defined(OS_IOS) |
| 61 return base::WrapUnique( | 61 return base::MakeUnique<IPC::AttachmentBrokerPrivilegedMac>(g_port_provider); |
| 62 new IPC::AttachmentBrokerPrivilegedMac(g_port_provider)); | |
| 63 #else | 62 #else |
| 64 return nullptr; | 63 return nullptr; |
| 65 #endif | 64 #endif |
| 66 } | 65 } |
| 67 | 66 |
| 68 // This class is wrapped in a LazyInstance to ensure that its constructor is | 67 // This class is wrapped in a LazyInstance to ensure that its constructor is |
| 69 // only called once. The constructor creates an attachment broker and sets it as | 68 // only called once. The constructor creates an attachment broker and sets it as |
| 70 // the global broker. | 69 // the global broker. |
| 71 class AttachmentBrokerMakeOnce { | 70 class AttachmentBrokerMakeOnce { |
| 72 public: | 71 public: |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 base::Unretained(this), pair, message)); | 162 base::Unretained(this), pair, message)); |
| 164 } | 163 } |
| 165 } | 164 } |
| 166 | 165 |
| 167 void AttachmentBrokerPrivileged::LogError(UMAError error) { | 166 void AttachmentBrokerPrivileged::LogError(UMAError error) { |
| 168 UMA_HISTOGRAM_ENUMERATION( | 167 UMA_HISTOGRAM_ENUMERATION( |
| 169 "IPC.AttachmentBrokerPrivileged.BrokerAttachmentError", error, ERROR_MAX); | 168 "IPC.AttachmentBrokerPrivileged.BrokerAttachmentError", error, ERROR_MAX); |
| 170 } | 169 } |
| 171 | 170 |
| 172 } // namespace IPC | 171 } // namespace IPC |
| OLD | NEW |