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

Side by Side Diff: content/browser/renderer_host/clipboard_message_filter_unittest.cc

Issue 2845113005: Replace base::SharedMemory read-only methods with GetReadOnlyHandle. (Closed)
Patch Set: Comments from thakis. Created 3 years, 7 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 | « base/metrics/field_trial.cc ('k') | extensions/browser/user_script_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/renderer_host/clipboard_message_filter.h" 5 #include "content/browser/renderer_host/clipboard_message_filter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 base::SharedMemoryCreateOptions options; 45 base::SharedMemoryCreateOptions options;
46 options.size = size; 46 options.size = size;
47 options.share_read_only = true; 47 options.share_read_only = true;
48 if (!m->Create(options)) 48 if (!m->Create(options))
49 return nullptr; 49 return nullptr;
50 return m; 50 return m;
51 } 51 }
52 52
53 void CallWriteImage(const gfx::Size& size, 53 void CallWriteImage(const gfx::Size& size,
54 base::SharedMemory* shared_memory) { 54 base::SharedMemory* shared_memory) {
55 base::SharedMemoryHandle handle; 55 base::SharedMemoryHandle handle = shared_memory->GetReadOnlyHandle();
56 ASSERT_TRUE(shared_memory->GiveReadOnlyToProcess( 56 shared_memory->Unmap();
57 base::GetCurrentProcessHandle(), &handle)); 57 shared_memory->Close();
58 ASSERT_TRUE(handle.IsValid());
58 CallWriteImageDirectly(size, handle); 59 CallWriteImageDirectly(size, handle);
59 } 60 }
60 61
61 // Prefer to use CallWriteImage() in tests. 62 // Prefer to use CallWriteImage() in tests.
62 void CallWriteImageDirectly(const gfx::Size& size, 63 void CallWriteImageDirectly(const gfx::Size& size,
63 base::SharedMemoryHandle handle) { 64 base::SharedMemoryHandle handle) {
64 filter_->OnWriteImage(ui::CLIPBOARD_TYPE_COPY_PASTE, size, handle); 65 filter_->OnWriteImage(ui::CLIPBOARD_TYPE_COPY_PASTE, size, handle);
65 } 66 }
66 67
67 void CallCommitWrite() { 68 void CallCommitWrite() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 CallWriteImageDirectly(gfx::Size(5, 5), base::SharedMemoryHandle()); 127 CallWriteImageDirectly(gfx::Size(5, 5), base::SharedMemoryHandle());
127 uint64_t sequence_number = 128 uint64_t sequence_number =
128 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE); 129 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE);
129 CallCommitWrite(); 130 CallCommitWrite();
130 131
131 EXPECT_EQ(sequence_number, 132 EXPECT_EQ(sequence_number,
132 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE)); 133 clipboard()->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE));
133 } 134 }
134 135
135 } // namespace content 136 } // namespace content
OLDNEW
« no previous file with comments | « base/metrics/field_trial.cc ('k') | extensions/browser/user_script_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698