Remove base::RefCountedSharedMemory (unused)

It is wrapping a deprecated class base::SharedMemory. All users of
base::RefCountedSharedMemory have been updated and this class is no
more used, it can be removed.

Chromium Shared Memory Refactor design doc:
https://docs.google.com/document/d/1lk2-7W7Cy7FDqG-6lgS8LRkzXABYTOytf6VUsWNf8-0/edit#heading=h.7nki9mck5t64

Bug: 795291
Change-Id: I67a7fa8a6103fc0813171c0a0b5b2965809cef2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1566294
Reviewed-by: Pavol Marko <pmarko@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#651177}
diff --git a/base/memory/ref_counted_memory.cc b/base/memory/ref_counted_memory.cc
index 23a5ffc..fa14015 100644
--- a/base/memory/ref_counted_memory.cc
+++ b/base/memory/ref_counted_memory.cc
@@ -83,26 +83,6 @@
   return data_.size();
 }
 
-RefCountedSharedMemory::RefCountedSharedMemory(
-    std::unique_ptr<SharedMemory> shm,
-    size_t size)
-    : shm_(std::move(shm)), size_(size) {
-  DCHECK(shm_);
-  DCHECK(shm_->memory());
-  DCHECK_GT(size_, 0U);
-  DCHECK_LE(size_, shm_->mapped_size());
-}
-
-RefCountedSharedMemory::~RefCountedSharedMemory() = default;
-
-const unsigned char* RefCountedSharedMemory::front() const {
-  return static_cast<const unsigned char*>(shm_->memory());
-}
-
-size_t RefCountedSharedMemory::size() const {
-  return size_;
-}
-
 RefCountedSharedMemoryMapping::RefCountedSharedMemoryMapping(
     ReadOnlySharedMemoryMapping mapping)
     : mapping_(std::move(mapping)), size_(mapping_.size()) {
diff --git a/base/memory/ref_counted_memory.h b/base/memory/ref_counted_memory.h
index 92a7d7b..7d0e32b 100644
--- a/base/memory/ref_counted_memory.h
+++ b/base/memory/ref_counted_memory.h
@@ -14,7 +14,6 @@
 #include "base/base_export.h"
 #include "base/macros.h"
 #include "base/memory/ref_counted.h"
-#include "base/memory/shared_memory.h"
 #include "base/memory/shared_memory_mapping.h"
 
 namespace base {
@@ -142,27 +141,6 @@
 };
 
 // An implementation of RefCountedMemory, where the bytes are stored in
-// SharedMemory.
-class BASE_EXPORT RefCountedSharedMemory : public RefCountedMemory {
- public:
-  // Constructs a RefCountedMemory object by taking ownership of an already
-  // mapped SharedMemory object.
-  RefCountedSharedMemory(std::unique_ptr<SharedMemory> shm, size_t size);
-
-  // RefCountedMemory:
-  const unsigned char* front() const override;
-  size_t size() const override;
-
- private:
-  ~RefCountedSharedMemory() override;
-
-  const std::unique_ptr<SharedMemory> shm_;
-  const size_t size_;
-
-  DISALLOW_COPY_AND_ASSIGN(RefCountedSharedMemory);
-};
-
-// An implementation of RefCountedMemory, where the bytes are stored in
 // ReadOnlySharedMemoryMapping.
 class BASE_EXPORT RefCountedSharedMemoryMapping : public RefCountedMemory {
  public:
diff --git a/base/memory/ref_counted_memory_unittest.cc b/base/memory/ref_counted_memory_unittest.cc
index d799517..9c59ac0 100644
--- a/base/memory/ref_counted_memory_unittest.cc
+++ b/base/memory/ref_counted_memory_unittest.cc
@@ -74,53 +74,6 @@
   EXPECT_EQ('e', mem->front()[9]);
 }
 
-TEST(RefCountedMemoryUnitTest, RefCountedSharedMemory) {
-  static const char kData[] = "shm_dummy_data";
-  auto shm = std::make_unique<SharedMemory>();
-  ASSERT_TRUE(shm->CreateAndMapAnonymous(sizeof(kData)));
-  memcpy(shm->memory(), kData, sizeof(kData));
-
-  auto mem =
-      MakeRefCounted<RefCountedSharedMemory>(std::move(shm), sizeof(kData));
-  ASSERT_EQ(sizeof(kData), mem->size());
-  EXPECT_EQ('s', mem->front()[0]);
-  EXPECT_EQ('h', mem->front()[1]);
-  EXPECT_EQ('_', mem->front()[9]);
-}
-
-TEST(RefCountedMemoryUnitTest, RefCountedSharedMemoryMapping) {
-  static const char kData[] = "mem_region_dummy_data";
-  scoped_refptr<RefCountedSharedMemoryMapping> mem;
-  {
-    MappedReadOnlyRegion region =
-        ReadOnlySharedMemoryRegion::Create(sizeof(kData));
-    ReadOnlySharedMemoryMapping ro_mapping = region.region.Map();
-    WritableSharedMemoryMapping rw_mapping = std::move(region.mapping);
-    ASSERT_TRUE(rw_mapping.IsValid());
-    memcpy(rw_mapping.memory(), kData, sizeof(kData));
-    mem = MakeRefCounted<RefCountedSharedMemoryMapping>(std::move(ro_mapping));
-  }
-
-  ASSERT_LE(sizeof(kData), mem->size());
-  EXPECT_EQ('e', mem->front()[1]);
-  EXPECT_EQ('m', mem->front()[2]);
-  EXPECT_EQ('o', mem->front()[8]);
-
-  {
-    MappedReadOnlyRegion region =
-        ReadOnlySharedMemoryRegion::Create(sizeof(kData));
-    WritableSharedMemoryMapping rw_mapping = std::move(region.mapping);
-    ASSERT_TRUE(rw_mapping.IsValid());
-    memcpy(rw_mapping.memory(), kData, sizeof(kData));
-    mem = RefCountedSharedMemoryMapping::CreateFromWholeRegion(region.region);
-  }
-
-  ASSERT_LE(sizeof(kData), mem->size());
-  EXPECT_EQ('_', mem->front()[3]);
-  EXPECT_EQ('r', mem->front()[4]);
-  EXPECT_EQ('i', mem->front()[7]);
-}
-
 TEST(RefCountedMemoryUnitTest, Equals) {
   std::string s1("same");
   scoped_refptr<RefCountedMemory> mem1 = RefCountedString::TakeString(&s1);
diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc
index 8537134..f3f9e67 100644
--- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc
+++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc
@@ -13,6 +13,7 @@
 
 #include "base/bind.h"
 #include "base/containers/flat_set.h"
+#include "base/files/file_util.h"
 #include "base/guid.h"
 #include "base/memory/ptr_util.h"
 #include "base/run_loop.h"
diff --git a/chrome/browser/chromeos/crostini/crostini_registry_service.cc b/chrome/browser/chromeos/crostini/crostini_registry_service.cc
index 9c6f9ec..2ac1dec 100644
--- a/chrome/browser/chromeos/crostini/crostini_registry_service.cc
+++ b/chrome/browser/chromeos/crostini/crostini_registry_service.cc
@@ -8,6 +8,7 @@
 
 #include "ash/public/cpp/app_list/app_list_config.h"
 #include "base/bind.h"
+#include "base/files/file_util.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/no_destructor.h"
 #include "base/strings/string_number_conversions.h"
diff --git a/chrome/browser/chromeos/drive/drivefs_test_support.cc b/chrome/browser/chromeos/drive/drivefs_test_support.cc
index 74c9e13..47cfcff 100644
--- a/chrome/browser/chromeos/drive/drivefs_test_support.cc
+++ b/chrome/browser/chromeos/drive/drivefs_test_support.cc
@@ -8,6 +8,7 @@
 #include <utility>
 
 #include "base/bind.h"
+#include "base/files/file_util.h"
 #include "base/json/json_writer.h"
 #include "base/path_service.h"
 #include "base/test/bind_test_util.h"
diff --git a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
index da21d9b..1a65f260 100644
--- a/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
+++ b/chrome/browser/chromeos/extensions/wallpaper_private_api.cc
@@ -11,6 +11,7 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/files/file_enumerator.h"
+#include "base/files/file_util.h"
 #include "base/macros.h"
 #include "base/memory/ref_counted_memory.h"
 #include "base/metrics/histogram_macros.h"
diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc
index 89b9b63..a634566 100644
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc
@@ -14,6 +14,7 @@
 #include "base/command_line.h"
 #include "base/feature_list.h"
 #include "base/files/file_path.h"
+#include "base/files/file_util.h"
 #include "base/logging.h"
 #include "base/memory/weak_ptr.h"
 #include "base/metrics/histogram_functions.h"
diff --git a/chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc b/chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc
index 7794988..2766e73 100644
--- a/chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc
+++ b/chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.cc
@@ -9,6 +9,7 @@
 
 #include "base/feature_list.h"
 #include "base/files/file_path.h"
+#include "base/files/file_util.h"
 #include "base/no_destructor.h"
 #include "base/strings/string_split.h"
 #include "base/system/sys_info.h"
diff --git a/chrome/browser/chromeos/login/startup_utils.cc b/chrome/browser/chromeos/login/startup_utils.cc
index 3744256..4f8c48e 100644
--- a/chrome/browser/chromeos/login/startup_utils.cc
+++ b/chrome/browser/chromeos/login/startup_utils.cc
@@ -9,6 +9,7 @@
 #include "base/bind.h"
 #include "base/callback.h"
 #include "base/command_line.h"
+#include "base/files/file_util.h"
 #include "base/path_service.h"
 #include "base/system/sys_info.h"
 #include "base/task/post_task.h"
diff --git a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
index 2b28c20..9bf7b83 100644
--- a/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
+++ b/chrome/browser/chromeos/policy/enrollment_handler_chromeos.cc
@@ -9,6 +9,7 @@
 #include "base/base64.h"
 #include "base/bind.h"
 #include "base/command_line.h"
+#include "base/files/file_util.h"
 #include "base/guid.h"
 #include "base/location.h"
 #include "base/logging.h"
diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
index a70b0ac..9a0fe68 100644
--- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
+++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
@@ -12,6 +12,7 @@
 #include "base/bind_helpers.h"
 #include "base/command_line.h"
 #include "base/files/file_path.h"
+#include "base/files/file_util.h"
 #include "base/memory/weak_ptr.h"
 #include "base/task/post_task.h"
 #include "base/values.h"
diff --git a/chrome/browser/web_applications/components/web_app_shortcut_linux.cc b/chrome/browser/web_applications/components/web_app_shortcut_linux.cc
index cd9d945..ff446fa 100644
--- a/chrome/browser/web_applications/components/web_app_shortcut_linux.cc
+++ b/chrome/browser/web_applications/components/web_app_shortcut_linux.cc
@@ -9,6 +9,7 @@
 #include "base/base_paths.h"
 #include "base/environment.h"
 #include "base/files/file_path.h"
+#include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/i18n/file_util_icu.h"
 #include "base/nix/xdg_util.h"