mfbt/SharedLibrary.h
author Petru Lingurar <petru.lingurar@softvision.ro>
Fri, 21 Dec 2018 08:56:47 +0000
changeset 501492 65621d0fe1262af0643cec37c23b2d9ec42588ad
parent 472888 af62a7677b23df7ea16511744b0c5095d7efc5de
child 508163 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
Bug 1513938 - Enforce a Bundle size limit and drop `privateSession` if exceeds it. r=JanH, a=jcristau The `privateSession` key would normally allow persisting the Private Browsing session across OOMs in Activity's Bundle. We need to do that to avoid storing private, sensible data on disk like we do with the normal browsing session. In some cases `privateSession` would contain a lot of data which, along with other possible concurrent transactions could overflow Binder's buffer which has a limited fixed size, currently 1Mb. To avoid this, we will drop `privateSession` from the Bundle if the resulting size is greater than a _speculative_ size of 300KBs which would mean that in the case of an OOM all Private Browsing state would be lost. Bug 1515592 is filed to investigate for a better solution. Differential Revision: https://phabricator.services.mozilla.com/D15067

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* Path charset agnostic wrappers for prlink.h. */

#ifndef mozilla_SharedLibrary_h
#define mozilla_SharedLibrary_h

#ifdef MOZILLA_INTERNAL_API

#include "prlink.h"
#include "mozilla/Char16.h"

namespace mozilla {

//
// Load the specified library.
//
// @param aPath  path to the library
// @param aFlags takes PR_LD_* flags (see prlink.h)
//
inline PRLibrary*
#ifdef XP_WIN
LoadLibraryWithFlags(char16ptr_t aPath, PRUint32 aFlags = 0)
#else
LoadLibraryWithFlags(const char* aPath, PRUint32 aFlags = 0)
#endif
{
  PRLibSpec libSpec;
#ifdef XP_WIN
  libSpec.type = PR_LibSpec_PathnameU;
  libSpec.value.pathname_u = aPath;
#else
  libSpec.type = PR_LibSpec_Pathname;
  libSpec.value.pathname = aPath;
#endif
  return PR_LoadLibraryWithFlags(libSpec, aFlags);
}

}  /* namespace mozilla */

#endif /* MOZILLA_INTERNAL_API */

#endif /* mozilla_SharedLibrary_h */