summaryrefslogtreecommitdiffstats
path: root/chrome/app/chrome_exe_main_gtk.cc
blob: 35764af33521cfaa69d868767ada7657fe1448a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/process_util.h"
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
#include "chrome/browser/first_run/first_run.h"
#endif

// The entry point for all invocations of Chromium, browser and renderer. On
// windows, this does nothing but load chrome.dll and invoke its entry point in
// order to make it easy to update the app from GoogleUpdate. We don't need
// that extra layer with on linux.
//
// TODO(tc): This is similar to chrome_exe_main_mac.mm.  After it's
// more clear what needs to go here, we should evaluate whether or not
// to merge this file with chrome_exe_main_mac.mm.

extern "C" {
int ChromeMain(int argc, const char** argv);

#if defined(OS_LINUX) && defined(USE_TCMALLOC)

int tc_set_new_mode(int mode);

#endif  // defined(OS_LINUX) && defined(USE_TCMALLOC)
}

int main(int argc, const char** argv) {
  base::EnableTerminationOnHeapCorruption();
  base::EnableTerminationOnOutOfMemory();

  // NOTE(willchan): One might ask why this call is done here rather than in
  // process_util_linux.cc with the definition of
  // EnableTerminationOnOutOfMemory().  That's because base shouldn't have a
  // dependency on TCMalloc.  Really, we ought to have our allocator shim code
  // implement this EnableTerminationOnOutOfMemory() function.  Whateverz.  This
  // works for now.
#if defined(OS_LINUX) && defined(USE_TCMALLOC)
  // For tcmalloc, we need to tell it to behave like new.
  tc_set_new_mode(1);
#endif

  // The exit manager is in charge of calling the dtors of singletons.
  // Win has one here, but we assert with multiples from BrowserMain() if we
  // keep it.
  // base::AtExitManager exit_manager;

  int return_code = ChromeMain(argc, argv);

#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
  // Launch a new instance if we're shutting down because we detected an
  // upgrade in the persistent mode.
  Upgrade::RelaunchChromeBrowserWithNewCommandLineIfNeeded();
#endif

  return return_code;
}