CINXE.COM
sql/initialization.cc - chromium/src - Git at Google
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>sql/initialization.cc - chromium/src - Git at Google</title><link rel="stylesheet" type="text/css" href="/+static/base.css"><link rel="stylesheet" type="text/css" href="/+static/prettify/prettify.css"><!-- default customHeadTagPart --></head><body class="Site"><header class="Site-header"><div class="Header"><a class="Header-image" href="/"><img src="//www.gstatic.com/images/branding/lockups/2x/lockup_git_color_108x24dp.png" width="108" height="24" alt="Google Git"></a><div class="Header-menu"> <a class="Header-menuItem" href="https://accounts.google.com/AccountChooser?faa=1&service=gerritcodereview&continue=https://chromium.googlesource.com/login/chromium/src/%2B/refs/tags/133.0.6850.2/sql/initialization.cc">Sign in</a> </div></div></header><div class="Site-content"><div class="Container "><div class="Breadcrumbs"><a class="Breadcrumbs-crumb" href="/?format=HTML">chromium</a> / <a class="Breadcrumbs-crumb" href="/chromium/">chromium</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/">src</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/133.0.6850.2">refs/tags/133.0.6850.2</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/133.0.6850.2/">.</a> / <a class="Breadcrumbs-crumb" href="/chromium/src/+/refs/tags/133.0.6850.2/sql">sql</a> / <span class="Breadcrumbs-crumb">initialization.cc</span></div><div class="u-sha1 u-monospace BlobSha1">blob: 8a56c2131263eb5902a242b23ce817dbeb07a735 [<a href="/chromium/src/+/refs/tags/133.0.6850.2/sql/initialization.cc">file</a>] [<a href="/chromium/src/+log/refs/tags/133.0.6850.2/sql/initialization.cc">log</a>] [<a href="/chromium/src/+blame/refs/tags/133.0.6850.2/sql/initialization.cc">blame</a>]</div><table class="FileContents"><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="1"></td><td class="FileContents-lineContents" id="1"><span class="com">// Copyright 2018 The Chromium Authors</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="2"></td><td class="FileContents-lineContents" id="2"><span class="com">// Use of this source code is governed by a BSD-style license that can be</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="3"></td><td class="FileContents-lineContents" id="3"><span class="com">// found in the LICENSE file.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="4"></td><td class="FileContents-lineContents" id="4"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="5"></td><td class="FileContents-lineContents" id="5"><span class="com">#include</span><span class="pln"> </span><span class="str">"sql/initialization.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="6"></td><td class="FileContents-lineContents" id="6"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="7"></td><td class="FileContents-lineContents" id="7"><span class="com">#include</span><span class="pln"> </span><span class="str">"base/no_destructor.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="8"></td><td class="FileContents-lineContents" id="8"><span class="com">#include</span><span class="pln"> </span><span class="str">"base/synchronization/lock.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="9"></td><td class="FileContents-lineContents" id="9"><span class="com">#include</span><span class="pln"> </span><span class="str">"base/trace_event/trace_event.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="10"></td><td class="FileContents-lineContents" id="10"><span class="com">#include</span><span class="pln"> </span><span class="str">"sql/vfs_wrapper.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="11"></td><td class="FileContents-lineContents" id="11"><span class="com">#include</span><span class="pln"> </span><span class="str">"third_party/sqlite/sqlite3.h"</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="12"></td><td class="FileContents-lineContents" id="12"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="13"></td><td class="FileContents-lineContents" id="13"><span class="kwd">namespace</span><span class="pln"> sql </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="14"></td><td class="FileContents-lineContents" id="14"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="15"></td><td class="FileContents-lineContents" id="15"><span class="kwd">void</span><span class="pln"> </span><span class="typ">EnsureSqliteInitialized</span><span class="pun">(</span><span class="kwd">bool</span><span class="pln"> create_wrapper</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="16"></td><td class="FileContents-lineContents" id="16"><span class="pln"> </span><span class="com">// sqlite3_initialize() uses double-checked locking and thus can have</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="17"></td><td class="FileContents-lineContents" id="17"><span class="pln"> </span><span class="com">// data races.</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="18"></td><td class="FileContents-lineContents" id="18"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> base</span><span class="pun">::</span><span class="typ">NoDestructor</span><span class="pun"><</span><span class="pln">base</span><span class="pun">::</span><span class="typ">Lock</span><span class="pun">></span><span class="pln"> sqlite_init_lock</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="19"></td><td class="FileContents-lineContents" id="19"><span class="pln"> base</span><span class="pun">::</span><span class="typ">AutoLock</span><span class="pln"> auto_lock</span><span class="pun">(*</span><span class="pln">sqlite_init_lock</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="20"></td><td class="FileContents-lineContents" id="20"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="21"></td><td class="FileContents-lineContents" id="21"><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">bool</span><span class="pln"> first_call </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="22"></td><td class="FileContents-lineContents" id="22"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">first_call</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="23"></td><td class="FileContents-lineContents" id="23"><span class="pln"> TRACE_EVENT0</span><span class="pun">(</span><span class="str">"sql"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"EnsureSqliteInitialized"</span><span class="pun">);</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="24"></td><td class="FileContents-lineContents" id="24"><span class="pln"> sqlite3_initialize</span><span class="pun">();</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="25"></td><td class="FileContents-lineContents" id="25"><span class="pln"> first_call </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="26"></td><td class="FileContents-lineContents" id="26"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="27"></td><td class="FileContents-lineContents" id="27"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="28"></td><td class="FileContents-lineContents" id="28"><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">create_wrapper</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="29"></td><td class="FileContents-lineContents" id="29"><span class="pln"> </span><span class="typ">EnsureVfsWrapper</span><span class="pun">();</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="30"></td><td class="FileContents-lineContents" id="30"><span class="pln"> </span><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="31"></td><td class="FileContents-lineContents" id="31"><span class="pun">}</span></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="32"></td><td class="FileContents-lineContents" id="32"></td></tr><tr class="u-pre u-monospace FileContents-line"><td class="u-lineNum u-noSelect FileContents-lineNum" data-line-number="33"></td><td class="FileContents-lineContents" id="33"><span class="pun">}</span><span class="pln"> </span><span class="com">// namespace sql</span></td></tr></table><script nonce="_8RmbA3mkM5vMjSo1sG-EA">for (let lineNumEl of document.querySelectorAll('td.u-lineNum')) {lineNumEl.onclick = () => {window.location.hash = `#${lineNumEl.getAttribute('data-line-number')}`;};}</script></div> <!-- Container --></div> <!-- Site-content --><footer class="Site-footer"><div class="Footer"><span class="Footer-poweredBy">Powered by <a href="https://gerrit.googlesource.com/gitiles/">Gitiles</a>| <a href="https://policies.google.com/privacy">Privacy</a>| <a href="https://policies.google.com/terms">Terms</a></span><span class="Footer-formats"><a class="u-monospace Footer-formatsItem" href="?format=TEXT">txt</a> <a class="u-monospace Footer-formatsItem" href="?format=JSON">json</a></span></div></footer></body></html>