Browse Source

refactor: move impl classes into unnamed namespaces (#42390)

* refactor: move ReplyChannel into an anonymous namespace

* refactor: move ChunkedDataPipeReadableStream into an anonymous namespace

* refactor: move linux helpers into an anonymous namespace

* refactor: move linux helpers into an anonymous namespace
Charles Kerr 10 months ago
parent
commit
f2481ed44f

+ 4 - 0
shell/browser/api/electron_api_web_contents.cc

@@ -1893,6 +1893,8 @@ void WebContents::OnFirstNonEmptyLayout(
   }
 }
 
+namespace {
+
 // This object wraps the InvokeCallback so that if it gets GC'd by V8, we can
 // still call the callback and send an error. Not doing so causes a Mojo DCHECK,
 // since Mojo requires callbacks to be called before they are destroyed.
@@ -1949,6 +1951,8 @@ class ReplyChannel : public gin::Wrappable<ReplyChannel> {
 
 gin::WrapperInfo ReplyChannel::kWrapperInfo = {gin::kEmbedderNativeGin};
 
+}  // namespace
+
 gin::Handle<gin_helper::internal::Event> WebContents::MakeEventWithSender(
     v8::Isolate* isolate,
     content::RenderFrameHost* frame,

+ 4 - 0
shell/browser/browser_linux.cc

@@ -25,6 +25,8 @@
 
 namespace electron {
 
+namespace {
+
 const char kXdgSettings[] = "xdg-settings";
 const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler";
 
@@ -84,6 +86,8 @@ bool SetDefaultWebClient(const std::string& protocol) {
   return ran_ok && exit_code == EXIT_SUCCESS;
 }
 
+}  // namespace
+
 void Browser::AddRecentDocument(const base::FilePath& path) {}
 
 void Browser::ClearRecentDocuments() {}

+ 4 - 4
shell/browser/electron_browser_main_parts_linux.cc

@@ -18,6 +18,10 @@
 #include "shell/common/thread_restrictions.h"
 #endif
 
+namespace electron {
+
+namespace {
+
 constexpr std::string_view kElectronOzonePlatformHint{
     "ELECTRON_OZONE_PLATFORM_HINT"};
 
@@ -55,10 +59,6 @@ bool HasWaylandDisplay(base::Environment* env) {
 constexpr char kPlatformX11[] = "x11";
 #endif
 
-namespace electron {
-
-namespace {
-
 // Evaluates the environment and returns the effective platform name for the
 // given |ozone_platform_hint|.
 // For the "auto" value, returns "wayland" if the XDG session type is "wayland",

+ 5 - 0
shell/common/gin_converters/net_converter.cc

@@ -250,6 +250,8 @@ bool Converter<net::HttpRequestHeaders>::FromV8(v8::Isolate* isolate,
   return true;
 }
 
+namespace {
+
 class ChunkedDataPipeReadableStream
     : public gin::Wrappable<ChunkedDataPipeReadableStream> {
  public:
@@ -489,9 +491,12 @@ class ChunkedDataPipeReadableStream
   v8::Global<v8::ArrayBufferView> buf_;
   gin_helper::Promise<int> promise_;
 };
+
 gin::WrapperInfo ChunkedDataPipeReadableStream::kWrapperInfo = {
     gin::kEmbedderNativeGin};
 
+}  // namespace
+
 // static
 v8::Local<v8::Value> Converter<network::ResourceRequestBody>::ToV8(
     v8::Isolate* isolate,