Bug 460546 - nsBrowserGlue should use a smart getter for the pref service. r=gavin
[wine-gecko.git] / storage / src / mozStorage.h
blob5a9901d65fa6ea92751e95414adaf8f4ffe1b879
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: sw=4 ts=4 sts=4
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is Oracle Corporation code.
18 * The Initial Developer of the Original Code is
19 * Oracle Corporation
20 * Portions created by the Initial Developer are Copyright (C) 2004
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
25 * Shawn Wilsher <me@shawnwilsher.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either the GNU General Public License Version 2 or later (the "GPL"), or
29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 #ifndef _MOZSTORAGE_H_
42 #define _MOZSTORAGE_H_
44 /**
45 * This file contains convenience methods for mozStorage.
48 /**
49 * Converts a SQLite return code to an nsresult return code.
51 * @param srv The SQLite return code.
52 * @return The corresponding nsresult code.
54 static nsresult
55 ConvertResultCode(int srv)
57 switch (srv) {
58 case SQLITE_OK:
59 case SQLITE_ROW:
60 case SQLITE_DONE:
61 return NS_OK;
62 case SQLITE_CORRUPT:
63 case SQLITE_NOTADB:
64 return NS_ERROR_FILE_CORRUPTED;
65 case SQLITE_PERM:
66 case SQLITE_CANTOPEN:
67 return NS_ERROR_FILE_ACCESS_DENIED;
68 case SQLITE_BUSY:
69 case SQLITE_LOCKED:
70 return NS_ERROR_FILE_IS_LOCKED;
71 case SQLITE_READONLY:
72 return NS_ERROR_FILE_READ_ONLY;
73 case SQLITE_FULL:
74 case SQLITE_TOOBIG:
75 return NS_ERROR_FILE_NO_DEVICE_SPACE;
76 case SQLITE_NOMEM:
77 return NS_ERROR_OUT_OF_MEMORY;
78 case SQLITE_MISUSE:
79 return NS_ERROR_UNEXPECTED;
80 case SQLITE_ABORT:
81 case SQLITE_INTERRUPT:
82 return NS_ERROR_ABORT;
85 // generic error
86 return NS_ERROR_FAILURE;
89 #endif // _MOZSTORAGE_H_