Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: mojo/edk/system/raw_channel_posix.cc

Issue 1641393002: Make //mojo/edk/system use //mojo/util's WeakPtr(Factory) instead of base's. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/raw_channel.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/edk/system/raw_channel.h" 5 #include "mojo/edk/system/raw_channel.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/uio.h> 8 #include <sys/uio.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <deque> 12 #include <deque>
13 #include <iterator> 13 #include <iterator>
14 #include <memory> 14 #include <memory>
15 #include <utility> 15 #include <utility>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/weak_ptr.h"
20 #include "mojo/edk/embedder/platform_channel_utils.h" 19 #include "mojo/edk/embedder/platform_channel_utils.h"
21 #include "mojo/edk/platform/platform_handle.h" 20 #include "mojo/edk/platform/platform_handle.h"
22 #include "mojo/edk/platform/platform_handle_watcher.h" 21 #include "mojo/edk/platform/platform_handle_watcher.h"
23 #include "mojo/edk/platform/scoped_platform_handle.h" 22 #include "mojo/edk/platform/scoped_platform_handle.h"
24 #include "mojo/edk/system/transport_data.h" 23 #include "mojo/edk/system/transport_data.h"
25 #include "mojo/edk/util/make_unique.h" 24 #include "mojo/edk/util/make_unique.h"
25 #include "mojo/edk/util/weak_ptr.h"
26 #include "mojo/public/cpp/system/macros.h" 26 #include "mojo/public/cpp/system/macros.h"
27 27
28 using mojo::platform::PlatformHandle; 28 using mojo::platform::PlatformHandle;
29 using mojo::platform::PlatformHandleWatcher; 29 using mojo::platform::PlatformHandleWatcher;
30 using mojo::platform::ScopedPlatformHandle; 30 using mojo::platform::ScopedPlatformHandle;
31 using mojo::util::MakeUnique; 31 using mojo::util::MakeUnique;
32 using mojo::util::MutexLocker; 32 using mojo::util::MutexLocker;
33 using mojo::util::WeakPtrFactory;
33 34
34 namespace mojo { 35 namespace mojo {
35 namespace system { 36 namespace system {
36 37
37 namespace { 38 namespace {
38 39
39 class RawChannelPosix final : public RawChannel { 40 class RawChannelPosix final : public RawChannel {
40 public: 41 public:
41 explicit RawChannelPosix(ScopedPlatformHandle handle); 42 explicit RawChannelPosix(ScopedPlatformHandle handle);
42 ~RawChannelPosix() override; 43 ~RawChannelPosix() override;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 std::unique_ptr<PlatformHandleWatcher::WatchToken> write_watch_token_; 83 std::unique_ptr<PlatformHandleWatcher::WatchToken> write_watch_token_;
83 84
84 bool pending_read_; 85 bool pending_read_;
85 86
86 std::deque<ScopedPlatformHandle> read_platform_handles_; 87 std::deque<ScopedPlatformHandle> read_platform_handles_;
87 88
88 bool pending_write_ MOJO_GUARDED_BY(write_mutex()); 89 bool pending_write_ MOJO_GUARDED_BY(write_mutex());
89 90
90 // This is used for posting tasks from write threads to the I/O thread. The 91 // This is used for posting tasks from write threads to the I/O thread. The
91 // weak pointers it produces are only used/invalidated on the I/O thread. 92 // weak pointers it produces are only used/invalidated on the I/O thread.
92 base::WeakPtrFactory<RawChannelPosix> weak_ptr_factory_ 93 WeakPtrFactory<RawChannelPosix> weak_ptr_factory_
93 MOJO_GUARDED_BY(write_mutex()); 94 MOJO_GUARDED_BY(write_mutex());
94 95
95 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannelPosix); 96 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannelPosix);
96 }; 97 };
97 98
98 RawChannelPosix::RawChannelPosix(ScopedPlatformHandle handle) 99 RawChannelPosix::RawChannelPosix(ScopedPlatformHandle handle)
99 : fd_(handle.Pass()), 100 : fd_(handle.Pass()),
100 pending_read_(false), 101 pending_read_(false),
101 pending_write_(false), 102 pending_write_(false),
102 weak_ptr_factory_(this) { 103 weak_ptr_factory_(this) {
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // ----------------------------------------------------------------------------- 476 // -----------------------------------------------------------------------------
476 477
477 // Static factory method declared in raw_channel.h. 478 // Static factory method declared in raw_channel.h.
478 // static 479 // static
479 std::unique_ptr<RawChannel> RawChannel::Create(ScopedPlatformHandle handle) { 480 std::unique_ptr<RawChannel> RawChannel::Create(ScopedPlatformHandle handle) {
480 return MakeUnique<RawChannelPosix>(handle.Pass()); 481 return MakeUnique<RawChannelPosix>(handle.Pass());
481 } 482 }
482 483
483 } // namespace system 484 } // namespace system
484 } // namespace mojo 485 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/raw_channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698