Move CopyablePtr from base to protozero

Non-functional change. Just limits the exposure of CopyablePtr.
It's used only by protozero generated code. Moving this keeps the
codebase easier to follow and reduces the protozero<>base surface.

Bug: 132880619
Change-Id: Ia9ddda3451fc0118886d26be26524fce9b2d5ea3
diff --git a/Android.bp b/Android.bp
index e6487db..ef62e6d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -4093,7 +4093,6 @@
   name: "perfetto_src_base_unittests",
   srcs: [
     "src/base/circular_queue_unittest.cc",
-    "src/base/copyable_ptr_unittest.cc",
     "src/base/metatrace_unittest.cc",
     "src/base/no_destructor_unittest.cc",
     "src/base/optional_unittest.cc",
@@ -4502,6 +4501,7 @@
 filegroup {
   name: "perfetto_src_protozero_unittests",
   srcs: [
+    "src/protozero/copyable_ptr_unittest.cc",
     "src/protozero/message_handle_unittest.cc",
     "src/protozero/message_unittest.cc",
     "src/protozero/proto_decoder_unittest.cc",
diff --git a/BUILD b/BUILD
index 80ba731..790411a 100644
--- a/BUILD
+++ b/BUILD
@@ -208,7 +208,6 @@
     srcs = [
         "include/perfetto/base/build_config.h",
         "include/perfetto/base/compiler.h",
-        "include/perfetto/base/copyable_ptr.h",
         "include/perfetto/base/export.h",
         "include/perfetto/base/logging.h",
         "include/perfetto/base/task_runner.h",
@@ -346,6 +345,7 @@
     name = "include_perfetto_protozero_protozero",
     srcs = [
         "include/perfetto/protozero/contiguous_memory_range.h",
+        "include/perfetto/protozero/copyable_ptr.h",
         "include/perfetto/protozero/field.h",
         "include/perfetto/protozero/message.h",
         "include/perfetto/protozero/message_handle.h",
diff --git a/include/perfetto/base/BUILD.gn b/include/perfetto/base/BUILD.gn
index 9dc0893..e490551 100644
--- a/include/perfetto/base/BUILD.gn
+++ b/include/perfetto/base/BUILD.gn
@@ -18,7 +18,6 @@
   sources = [
     "build_config.h",
     "compiler.h",
-    "copyable_ptr.h",
     "export.h",
     "logging.h",
     "task_runner.h",
diff --git a/include/perfetto/protozero/BUILD.gn b/include/perfetto/protozero/BUILD.gn
index 7749684..994ff60 100644
--- a/include/perfetto/protozero/BUILD.gn
+++ b/include/perfetto/protozero/BUILD.gn
@@ -18,6 +18,7 @@
   ]
   sources = [
     "contiguous_memory_range.h",
+    "copyable_ptr.h",
     "field.h",
     "message.h",
     "message_handle.h",
diff --git a/include/perfetto/base/copyable_ptr.h b/include/perfetto/protozero/copyable_ptr.h
similarity index 92%
rename from include/perfetto/base/copyable_ptr.h
rename to include/perfetto/protozero/copyable_ptr.h
index 236382f..2fe5ff6 100644
--- a/include/perfetto/base/copyable_ptr.h
+++ b/include/perfetto/protozero/copyable_ptr.h
@@ -14,13 +14,12 @@
  * limitations under the License.
  */
 
-#ifndef INCLUDE_PERFETTO_BASE_COPYABLE_PTR_H_
-#define INCLUDE_PERFETTO_BASE_COPYABLE_PTR_H_
+#ifndef INCLUDE_PERFETTO_PROTOZERO_COPYABLE_PTR_H_
+#define INCLUDE_PERFETTO_PROTOZERO_COPYABLE_PTR_H_
 
 #include <memory>
 
-namespace perfetto {
-namespace base {
+namespace protozero {
 
 // This class is essentially a std::vector<T> of fixed size = 1.
 // It's a pointer wrapper with deep copying and deep equality comparison.
@@ -83,7 +82,6 @@
   std::unique_ptr<T> ptr_;
 };
 
-}  // namespace base
-}  // namespace perfetto
+}  // namespace protozero
 
-#endif  // INCLUDE_PERFETTO_BASE_COPYABLE_PTR_H_
+#endif  // INCLUDE_PERFETTO_PROTOZERO_COPYABLE_PTR_H_
diff --git a/src/base/BUILD.gn b/src/base/BUILD.gn
index 9f53d4b..0e7a0d0 100644
--- a/src/base/BUILD.gn
+++ b/src/base/BUILD.gn
@@ -122,7 +122,6 @@
 
   sources = [
     "circular_queue_unittest.cc",
-    "copyable_ptr_unittest.cc",
     "no_destructor_unittest.cc",
     "optional_unittest.cc",
     "paged_memory_unittest.cc",
diff --git a/src/protozero/BUILD.gn b/src/protozero/BUILD.gn
index bcc34e0..b2cc13a 100644
--- a/src/protozero/BUILD.gn
+++ b/src/protozero/BUILD.gn
@@ -57,6 +57,7 @@
     "../base:test_support",
   ]
   sources = [
+    "copyable_ptr_unittest.cc",
     "message_handle_unittest.cc",
     "message_unittest.cc",
     "proto_decoder_unittest.cc",
diff --git a/src/base/copyable_ptr_unittest.cc b/src/protozero/copyable_ptr_unittest.cc
similarity index 94%
rename from src/base/copyable_ptr_unittest.cc
rename to src/protozero/copyable_ptr_unittest.cc
index ecbd1ef..d9be950 100644
--- a/src/base/copyable_ptr_unittest.cc
+++ b/src/protozero/copyable_ptr_unittest.cc
@@ -14,12 +14,11 @@
  * limitations under the License.
  */
 
-#include "perfetto/base/copyable_ptr.h"
+#include "perfetto/protozero/copyable_ptr.h"
 
 #include "test/gtest_and_gmock.h"
 
-namespace perfetto {
-namespace base {
+namespace protozero {
 namespace {
 
 struct X {
@@ -116,5 +115,4 @@
 }
 
 }  // namespace
-}  // namespace base
-}  // namespace perfetto
+}  // namespace protozero
diff --git a/src/protozero/protoc_plugin/cppgen_plugin.cc b/src/protozero/protoc_plugin/cppgen_plugin.cc
index b396a67..e50c01e 100644
--- a/src/protozero/protoc_plugin/cppgen_plugin.cc
+++ b/src/protozero/protoc_plugin/cppgen_plugin.cc
@@ -121,7 +121,7 @@
   h_printer.Print("#include <vector>\n");
   h_printer.Print("#include <string>\n");
   h_printer.Print("#include <type_traits>\n\n");
-  h_printer.Print("#include \"perfetto/base/copyable_ptr.h\"\n");
+  h_printer.Print("#include \"perfetto/protozero/copyable_ptr.h\"\n");
   h_printer.Print("#include \"perfetto/base/export.h\"\n\n");
 
   cc_printer.Print(kHeader);
@@ -426,7 +426,7 @@
     } else if (!field->is_repeated()) {
       std::string type = GetCppType(field, false);
       if (field->type() == TYPE_MESSAGE) {
-        type = "::perfetto::base::CopyablePtr<" + type + ">";
+        type = "::protozero::CopyablePtr<" + type + ">";
         p->Print("$t$ $n$_;\n", "t", type, "n", field->lowercase_name());
       } else {
         p->Print("$t$ $n$_{};\n", "t", type, "n", field->lowercase_name());